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

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;

Related

Error trying to use a textview and a radiogroup within an LinearLayout

I am making a layout within Xamarin Android, but I find a problem and it is that when using a LinearLayout to group a text view and a radio group, the radio group is not generated on the screen only the text view, that is It seems that the radio group did not exist.
This is my Qr.axml:
<?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:id="#+id/container"
android:layout_width="match_parent"
android:background="#android:color/white"
android:screenOrientation="portrait"
android:layout_height="match_parent">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:screenOrientation="portrait"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="#layout/toolbar1"
android:id="#+id/toolbar">
</include>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1014dp"
android:layout_marginLeft="23dp"
android:text="Odometro dañado"
android:visibility="gone"
android:textColor="#android:color/background_dark"
android:id="#+id/Lbl_odometro">
</TextView>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="717dp"
android:layout_marginLeft="15dp"
android:id="#+id/radio_3"
android:orientation="vertical">
<RadioButton
android:id="#+id/radio_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Si"
android:onClick="radioButton_OnClick">
</RadioButton>
<RadioButton
android:id="#+id/radio_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No"
android:onClick="radioButton_OnClick">
</RadioButton>
</RadioGroup>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="692dp"
android:layout_marginLeft="255dp"
android:text="Tapa dañada"
android:textColor="#android:color/background_dark"
android:id="#+id/Lbl_Mensaje">
</TextView>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="717dp"
android:layout_marginLeft="255dp"
android:id="#+id/checkbox_meat"
android:orientation="vertical">
<RadioButton
android:id="#+id/checkbox_meat_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Si"
android:onClick="radioButton_OnClick">
</RadioButton>
<RadioButton
android:id="#+id/checkbox_meat_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No"
android:onClick="radioButton_OnClick">
</RadioButton>
</RadioGroup>
</LinearLayout>
</RelativeLayout>
</ScrollView>
<EDMTDev.ZXingXamarinAndroid.ZXingScannerView
android:id="#+id/zxscan"
android:layout_above="#+id/layout_result"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:screenOrientation="portrait">
<EDMTDev.ZXingXamarinAndroid.ZXingScannerView
android:id="#+id/zxscan"
android:layout_above="#+id/layout_result"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:screenOrientation="portrait"
android:minWidth="25px"
android:minHeight="25px" >
</EDMTDev.ZXingXamarinAndroid.ZXingScannerView>
</EDMTDev.ZXingXamarinAndroid.ZXingScannerView>
<LinearLayout
android:id="#+id/layout_result"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:padding="8dp"
android:background="#android:color/white"
android:visibility = "invisible"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</RelativeLayout>
I tried using a RelativeLayout for grouping, but the problem is that when I generate a background for it, it makes the whole layout get lost.
RadioGroup could do like "LinearLayout". You could try the xml below.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="Odometro dañado"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/radio_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Si"
android:onClick="radioButton_OnClick">
</RadioButton>
<RadioButton
android:id="#+id/radio_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No"
android:onClick="radioButton_OnClick">
</RadioButton>
</RadioGroup>
<TextView
android:text="Tapa dañada"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/checkbox_meat">
<RadioButton
android:id="#+id/checkbox_meat_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Si"
android:onClick="radioButton_OnClick">
</RadioButton>
<RadioButton
android:id="#+id/checkbox_meat_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No"
android:onClick="radioButton_OnClick">
</RadioButton>
</RadioGroup>
</RadioGroup>
</ScrollView>
</RelativeLayout >
Screenshot:

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

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>

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 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