Layout is not going to the bottom! It's on the side - c#

When I create a new Layout, it is appearing on the right side of the screen. I want it to be at the bottom, below my linear layout. Example in the picture.
LayoutPicture

Do you want to achieve result like following GIF?
if so, you can add the android:gravity="bottom" in the outside LinearLayout, here is my layout xml(If you want layout to the bottom-center, you can use android:gravity="bottom|center").
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
>
<LinearLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="First Name"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Last Name"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="UserName"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Password"
/>
<LinearLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Password"
android:textColor="#android:color/black"
/>
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Email"
/>
</LinearLayout>
update
Do you want to achieve the result like following layout??
If so, Here is code.
android:layout_width="match_parent"
android:layout_height="match_parent"
>
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="First Name"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Last Name"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="UserName"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Password"
/>
<LinearLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Password"
android:textColor="#android:color/black"
/>
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="Email"
/>
</LinearLayout>

Make sure to set the orientation of the parent layout to vertical. It is horizontal by default.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- your inner layouts here -->
</LinearLayout>

Related

Same Design on different Android versions

I am new at Xamarin and started working with it yesturday. I am trying to make an Android App using it in Visual Studio 2017, it works fine on Android Version 8.0, but on v. 7.0 the control elements on the screen get into different places.
Android 8.0:
Android 7.0:
Designer code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="Available Queries:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/queriescnt"
android:textAlignment="center" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/queriescnt"
android:id="#+id/email"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="35dp"
android:layout_marginRight="326.0dp"
android:singleLine="true" />
<Button
android:text="Search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/email"
android:id="#+id/submit"
android:layout_marginVertical="20dp"
android:layout_marginHorizontal="10dp" />
<EditText
android:layout_width="249.0dp"
android:layout_height="wrap_content"
android:layout_below="#id/submit"
android:id="#+id/keybox"
android:layout_marginVertical="300dp"
android:layout_marginHorizontal="50dp"
android:layout_marginRight="201.5dp"
android:password="true"
android:inputType="none|textPassword" />
<TextView
android:text="KEY:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/submit"
android:id="#+id/textView1"
android:layout_marginVertical="320dp"
android:layout_marginHorizontal="10dp" />
<CheckBox
android:text="S"
android:layout_width="54.5dp"
android:layout_height="wrap_content"
android:layout_below="#id/submit"
android:id="#+id/store"
android:layout_marginVertical="315dp"
android:layout_marginHorizontal="300dp" />
<TextView
android:text="Current line count:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/submit"
android:id="#+id/dbcount"
android:gravity="center_horizontal|center_vertical"
android:textSize="40dp"
android:inputType="none|textMultiLine" />
</RelativeLayout>
Can you please help me to make all the elements appear the same on different versions? I would be really thankful, if you also suggest me, what i can do better.
Your margins are messing up your layout. You cannot just add more margin to a view to position it relatively to another view.
I have adjusted your layout to match what you have in the first screen shot.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/queriescnt"
android:text="Available Queries:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/queriescnt"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="35dp"
android:maxLines="1" />
<Button
android:id="#+id/submit"
android:text="Search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/email"
android:layout_marginVertical="20dp"
android:layout_marginHorizontal="10dp" />
<TextView
android:id="#+id/dbcount"
android:text="Current line count:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/submit"
android:gravity="center_horizontal|center_vertical"
android:textSize="40dp"
android:inputType="none|textMultiLine" />
<TextView
android:id="#+id/textView1"
android:text="KEY:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"/>
<CheckBox
android:id="#+id/store"
android:text="S"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_margin="10dp"
android:layout_alignParentBottom="true" />
<EditText
android:id="#+id/keybox"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:password="true"
android:inputType="none|textPassword"
android:layout_alignBaseline="#+id/textView1"
android:layout_toEndOf="#+id/textView1"
android:layout_toStartOf="#+id/store"
tools:text="abc" />
</RelativeLayout>
What you may notice here is that I use toEndOf, toStartOf, alignBaseline, alignParentStart, alignParentEnd and alignParentBottom instead of the margins you had.
Simply adding 300dp margin to a view may work in the view port of the preview of the designer while you are fiddling with it. However not all screens have equal width and height both in physical size and in pixel density. Hence, 300dp will not look the same on all screens.
You can try the following code. I have tested the code on Android 7.0 and Android 8.0, it works properly.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="Available Queries:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/queriescnt"
android:textAlignment="center" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/queriescnt"
android:id="#+id/email"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="35dp"
android:layout_marginRight="326.0dp"
android:singleLine="true" />
<Button
android:text="Search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/email"
android:id="#+id/submit"
android:layout_marginVertical="20dp"
android:layout_marginHorizontal="10dp" />
<TextView
android:text="Current line count:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/submit"
android:id="#+id/dbcount"
android:gravity="center_horizontal|center_vertical"
android:textSize="40dp"
android:inputType="none|textMultiLine" />
<LinearLayout
android:layout_marginTop="200dp"
android:gravity="center"
android:layout_marginBottom="12dp"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/dbcount"
android:orientation="horizontal">
<TextView
android:text="KEY:"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView1"
android:layout_marginHorizontal="10dp" />
<EditText
android:hint="input"
android:layout_width="249.0dp"
android:layout_height="wrap_content"
android:id="#+id/keybox"
android:layout_toRightOf="#id/textView1"
android:password="true"
android:inputType="none|textPassword" />
<CheckBox
android:text="S"
android:layout_width="54.5dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/keybox"
android:id="#+id/store"/>
</LinearLayout>
</RelativeLayout>
Android 7.0
enter image description here
Android 8.0
enter image description here
Note:
You could include the three controls(TextView, EditText, CheckBox) into a parent layout(eg. LinearLayout), then you do not need to set the properties for each three controls.
The layout_below perperty you set is not right. When you add the parent layout for the below controls, you just need to add the property for the parent layout.
android:layout_below="#id/dbcount"

Floating Action Button cannot be "found"

I have the following axml which includes a Floating Action Button which I use to provide instructions to the user. Originally I wasn't able to have the button float correctly at the bottom right of the screen because of the scrollview, but was fixed here: Floating action button over a scrollview stuck at top. Now that the button "floats" correctly, FindViewById can't find it! No idea whats going on, how can I fix this?
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:src="#drawable/Banner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="center"
android:layout_marginTop="0sp"
android:background="#000000" />
<TextView
android:text="New Account"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView1"
android:textAlignment="center" />
</LinearLayout>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="Enter Username"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="150.5dp"
android:layout_height="wrap_content"
android:id="#+id/textView1"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/aTextboxUsername" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="Enter Password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="150.5dp"
android:layout_height="wrap_content"
android:id="#+id/textView1"/>
<EditText
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/aTextboxPassword"
android:autoLink="none" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="Confirm Password"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="150.5dp"
android:layout_height="wrap_content"
android:id="#+id/textView1"/>
<EditText
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/aTextboxPassword2"
android:autoLink="none" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="Enter Email Address"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="192.5dp"
android:layout_height="wrap_content"
android:id="#+id/textView1"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtEmailAddress"
android:autoLink="none" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="Confirm Email Address"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="193.5dp"
android:layout_height="wrap_content"
android:id="#+id/textView1"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtEmailAddress2"
android:autoLink="none" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="First Name" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/firstname"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="Middle Initial" />
<EditText
android:layout_width="50dp"
android:layout_height="wrap_content"
android:maxLength = "1"
android:id="#+id/mi"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="Last Name" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/lastname"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="130dp"
android:layout_height="35dp"
android:text="Suffix" />
<Spinner
android:layout_width="110dp"
android:layout_height="35dp"
android:id="#+id/spinner_suffix" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="Address" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/address"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="City" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/city"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="State" />
<Spinner
android:layout_width="110dp"
android:layout_height="35dp"
android:id="#+id/state" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="Zip Code" />
<EditText
android:layout_width="50dp"
android:layout_height="wrap_content"
android:maxLength = "5"
android:id="#+id/zip"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="Contact Phone" />
<MaskedEditText.MaskedEditText
app:Mask="(###) ###-####"
app:MaskFill="_"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/phone"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="center"
android:layout_marginTop="0sp"
android:background="#000000" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="Select Company, Department, Section you are registering for." />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="center"
android:layout_marginTop="0sp"
android:background="#000000" />
<TextView
android:text="Select Company"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textStyle="bold"
android:id="#+id/textView2" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:id="#+id/company_spinner" />
<TextView
android:text="Select Department"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textStyle="bold"
android:id="#+id/textView2" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:id="#+id/department_spinner" />
<TextView
android:text="Select Section"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textStyle="bold"
android:id="#+id/textView2" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:id="#+id/section_spinner" />
<Button
android:text="Submit"
android:layout_width="250px"
android:layout_gravity="center"
android:layout_height="34.5dp"
android:id="#+id/button_submit" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/fab_margin"
app:layout_anchorGravity="bottom|end"
app:layout_anchor="#id/scrollView1"
android:src="#drawable/alert_box" />
</android.support.design.widget.CoordinatorLayout>
* EDIT *
The FindViewById Code:
FloatingActionButton myFab = FindViewById<FloatingActionButton>(Resource.Id.fab);`
Please delete the "bin" and "obj" folder in your project, after that, rebuild your project.

Xamarin.Android Spinner & TextView Align

I'm developing a Xamarin.Android application using VS2017. I want to create a form as in the image.
How to create it? I find it difficult to align TextView & Spinner.
My output:
This is my code.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/intialPadding"
android:background="#color/windowBackground">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="#dimen/textInputLayoutHeight">
<EditText
android:id="#+id/edt_RefuelingDate1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorSecondaryText"
android:layout_gravity="center"
android:hint="Date"
android:inputType="date" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="#dimen/textInputLayoutHeight"
android:layout_gravity="center">
<TextView
android:text="Vehicle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:textSize="10dp"
android:paddingLeft="5dp" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/Widget.AppCompat.Spinner.Underlined"
android:id="#+id/spnrRefuelingVehicle"
android:layout_marginBottom="1.5dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="#dimen/textInputLayoutHeight"
android:layout_gravity="center">
<TextView
android:text="Fuel Type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView1"
android:textSize="10dp"
android:paddingLeft="5dp" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/Widget.AppCompat.Spinner.Underlined"
android:id="#+id/spnr_RefuelingFuelType1"
android:hint="Fuel Type" />
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/tilRefuelingFuelPrice1"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="#dimen/textInputLayoutHeight">
<EditText
android:hint="Fuel Price"
android:inputType="numberDecimal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorSecondaryText"
android:id="#+id/edt_RefuelingFuelPrice1" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/tilRefuelingOdometer1"
android:layout_width="match_parent"
android:layout_height="#dimen/textInputLayoutHeight">
<EditText
android:hint="Odometer"
android:inputType="numberDecimal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorSecondaryText"
android:id="#+id/edt_RefuelingOdometer1" />
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.design.widget.TextInputLayout
android:id="#+id/tilRefuelingAmount1"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="#dimen/textInputLayoutHeight">
<EditText
android:hint="Amount"
android:inputType="numberDecimal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorSecondaryText"
android:id="#+id/edt_RefuelingAmount1" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/tilRefuelingQuantity1"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="#dimen/textInputLayoutHeight">
<EditText
android:hint="Quantity"
android:inputType="numberDecimal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorSecondaryText"
android:id="#+id/edt_RefuelingQuantity1" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:text="Fuel Efficiency"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView1"
android:textSize="10dp"
android:paddingLeft="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/tv_RefuelingAverage"
android:gravity="center_vertical"
android:text="Fuel Efficiency"
android:textAlignment="center"
android:paddingLeft="8dp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
I was able to achieve it by using TableLayout.
Code:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="#dimen/intialPadding"
android:background="#color/windowBackground">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="Vehicle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/spnrRefuelingVehicle" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="Fuel Type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="Fuel Price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/spnr_RefuelingFuelType1" />
<TextView
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/edt_RefuelingFuelPrice1" />
</TableRow>
</TableLayout>
Output

How to display details on the right panel of tablet in xamarin

I have this layout in xamarin:
On the left panel are the list of Orders.
Every time you click an item, it should be displayed on the right panel.
But what happens is this, the detail pop ups:
This is the code for the details:
public class InProgressFragment : Fragment, SwipeRefreshLayout.IOnRefreshListener
{
RecyclerView mRecyclerView;
RecyclerView.LayoutManager mLayoutManager;
SwipeRefreshLayout mSwipeRefreshLayout;
InProgressAdapter mAdapter;
List<DTO.Order> mOrders;
void OnItemClick (object sender, int position)
{
var InProgressDetailsActivity = new Intent (Activity, typeof(InProgressDetailsActivity));
InProgressDetailsActivity.PutExtra ("TransactionID", mOrders [position].TransactionId);
InProgressDetailsActivity.PutExtra ("UpdatedBy", mOrders [position].UpdateBy);
InProgressDetailsActivity.PutExtra ("DatePaid", mOrders[position].DatePaid != null ?
mOrders [position].DatePaid.Value.ToString ("ddd, MMM d h:mm tt", CultureInfo.CreateSpecificCulture ("en-US")) : "n/a");
InProgressDetailsActivity.PutExtra ("Remarks", mOrders [position].UserRemarks);
InProgressDetailsActivity.PutExtra ("ShippingMethod", mOrders [position].ShippingMethod);
InProgressDetailsActivity.PutExtra ("CustomerName", mOrders [position].UserName);
InProgressDetailsActivity.PutExtra ("AddressPK", mOrders [position].AddressPartitionKey);
InProgressDetailsActivity.PutExtra ("AddressRK", mOrders [position].AddressRowKey);
InProgressDetailsActivity.PutExtra ("Paid", mOrders [position].Paid);
StartActivity (InProgressDetailsActivity);
}
.
.
.
And here is the View under layout-large. The detail view is just a mockup:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="match_parent"
android:background="#f2f2f2"
android:paddingRight="2dp"
android:id="#+id/relativeLayout1">
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<include
android:id="#+id/toolbar"
layout="#layout/GrabhutToolbar" />
<com.refractored.PagerSlidingTabStrip
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:pstsDividerWidth="0dp"
app:pstsDividerPadding="12dp"
app:pstsShouldExpand="true"
app:pstsIndicatorHeight="5dp"
app:pstsUnderlineColor="#000000"
app:pstsTabPaddingLeftRight="14dp"
app:pstsIndicatorColor="#android:color/holo_orange_light"
app:pstsDividerColor="#ffffff" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:context=".MainActivity" />
</LinearLayout>
</RelativeLayout>
<!--' DETAILVIEW '-->
<RelativeLayout
android:layout_weight="2"
android:layout_width="0px"
android:layout_height="match_parent"
android:id="#+id/relativeLayout2"
android:minWidth="25px"
android:minHeight="25px"
android:background="#ffffffff"
android:padding="16dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/details">
<include
android:id="#+id/toolbar"
layout="#layout/GrabhutToolbar" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px"
android:padding="16dp">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:paddingBottom="16dp">
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/TransactionID"
android:layout_marginBottom="16dp"
android:textColor="#ffec6206"
android:textStyle="bold"
android:text="TRANSACTION ID" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp">
<TextView
android:text="Processed By : "
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#ff505050" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/ProcessedBy"
android:textColor="#ff797979" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp">
<TextView
android:text="Paid On : "
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#ff505050" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/DatePaid"
android:textColor="#ff797979" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="Remarks : "
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#ff505050" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/Remarks"
android:textColor="#ff797979" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingBottom="20dp"
android:layout_marginBottom="2dp">
<TextView
android:text="Shipping Details"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff505050"
android:textStyle="bold"
android:layout_marginBottom="16dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp">
<ImageView
android:src="#drawable/ic_local_shipping_grey600_48dp"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/ShippingMethod"
android:textColor="#ff797979"
android:layout_marginLeft="8dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp">
<ImageView
android:src="#drawable/ic_room_grey600_48dp"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/Address"
android:textColor="#ff797979"
android:layout_marginLeft="8dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp">
<ImageView
android:src="#drawable/user"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical" />
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/CustomerName"
android:textColor="#ff797979"
android:layout_marginLeft="8dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:minWidth="25px"
android:minHeight="25px"
android:gravity="right">
<Button
android:text="SCHEDULE"
android:textColor="#ffffffff"
android:textStyle="bold"
android:background="#color/orange"
android:id="#+id/Schedule"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/orderitems" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Why you dont use fragments? It's the best for your case, check here about fragments and dual panel
Also i dont see the reason to intent so many data, you can use the Application class to store your whole object this way:
namespace myApplication
{
[Application]
public class myApplication : Application
{
public bool enabled; {get; set;}
public override void OnCreate()
{
base.OnCreate();
enabled = false;
}
}
And to use this object in this way:
App _app = (App)Application.Context;
_app.enabled = true;

How to Dock a control in Monodroid?

I want to dock the image-button (btn_add) to bottom of the activity.
I found couple of similar questions on there but they were useless for me.
Because of the way I used Scroll & Linear & Relative layout.
(Actually I can't set a relative-layout as the main layout of my activity as they said)
How can I do it ?
Please help!
My activity :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="Count"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textView3" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="Question Count"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textView3" />
<EditText
android:inputType="text"
android:layout_width="65.0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left"
android:id="#+id/txt_totalCount"
android:text="" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="True Count"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textView3" />
<EditText
android:inputType="text"
android:layout_width="65.0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left"
android:id="#+id/txt_trueCount"
android:text="" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="False Count"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textView3" />
<EditText
android:inputType="text"
android:layout_width="65.0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left"
android:id="#+id/txt_falseCount"
android:text="" />
<TextView
android:text="Num"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textView3" />
<EditText
android:inputType="text"
android:layout_width="65.0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left"
android:id="#+id/txt_number"
android:text="" />
</RelativeLayout>
<RadioGroup
android:gravity="right"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/rdoGroup">
<TextView
android:text="Has Negative"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Yeah"
android:gravity="right"
android:id="#+id/rdo_true"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nope"
android:gravity="right"
android:id="#+id/rdo_false"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RadioGroup>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:text="Percent"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textView4" />
<EditText
android:inputType="text"
android:layout_width="65.0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="left"
android:id="#+id/txt_percent"
android:text="" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<ImageButton
android:src="#drawable/create_icon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="#+id/btn_add" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
You should set the property "FillViewPort" on the scrollview on true. Like this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
That should do the trick!

Categories

Resources