Dilshad Abduwali
Dilshad Abduwali

Reputation: 1458

How do I set the Button all the way down of the main layout in Android?

Hi I am new in Android and I am making a simple xml layout and one button named show should be very end of the main layout, I could not figure it out how to do it, can anyone give some clue?

XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TableLayout 
    android:id="@+id/form"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TableRow 
        android:id="@+id/fnameRow"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView 
            android:id="@+id/fnameTxt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:text="Firstname"/>

        <EditText 
            android:id="@+id/fnameEdit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />"

    </TableRow>

    <TableRow 
        android:id="@+id/lnameRow"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView 
            android:id="@+id/lnameTxt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:text="Lastname"/>

        <EditText
            android:id="@+id/lnameEdit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="10" >

            <requestFocus />
        </EditText>

    </TableRow>

</TableLayout>

<Button 
    android:id="@+id/showBtn"
    android:layout_below="@id/form"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Show" />
</RelativeLayout>

Upvotes: 0

Views: 77

Answers (1)

jbr3zy
jbr3zy

Reputation: 654

try adding the android:layout_alignParentBottom attribute to the button

Upvotes: 4

Related Questions