techno techno - 4 months ago 33
Android Question

Align Buttons in Linear Layout to the Bottom of the Screen

I have the following layout

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ImageView
android:id="@+id/imageView1"
android:layout_gravity="center"
android:layout_width="200dip"
android:layout_height="200dip"


/>
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content" />


<LinearLayout
android:layout_marginLeft="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
android:id="@+id/tview_total"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Total Files Processed:" />

<TextView
android:id="@+id/tview_success"
android:layout_width="match_parent"
android:gravity="right"
android:layout_height="wrap_content"
android:text="Successfully Processed:" />

<TextView
android:id="@+id/tview_error"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:text="Error Processing:" />

</LinearLayout>


<LinearLayout
android:id="@+id/llBottomContainer2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
android:gravity="bottom"
android:padding="5dp" >
<Button
android:id="@+id/proceed2"
style="@style/btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/btn_sel"
android:text="Proceed" />
</LinearLayout>
</LinearLayout>


I want to align the Button on the bottom of the screen.I tried setting

android:layout_gravity="bottom"
android:gravity="bottom"


Does not work.What i'm i doing wrong?

Answer

try this :

<LinearLayout
        android:id="@+id/llBottomContainer2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:layout_gravity="bottom"
        android:gravity="bottom"
        android:padding="5dp" >