Xamarin – Display Fixed Layout at the bottom in Android


In some design scenarios, where we would require a fixed layout at the bottom of the screen. The fixed layout may contain a set of controls. In this post, we would see how do we do that.

Here is a sample layout with ListView.

As you see in above image, the last control before the Fixed Layout, should have the above properties with values.

Now, the Linear Layout would become fixed at the bottom, once you apply the style of ButtonBar.

Now the Button inside it, is the content of the fixed layout.

Hope this quick post helps, thanks for reading.

The following is the xml for your reference.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ListView

android:layout_width="fill_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:id="@+id/listView1" />

<LinearLayout

style="@android:style/ButtonBar"

android:orientation="horizontal"

android:layout_width="fill_parent"

android:layout_height="wrap_content">

<Button

android:text="Done"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:id="@+id/button1" />

</LinearLayout>

</LinearLayout>
Advertisements