Aligning buttons to the bottom/footer of the page easily Android

A simple easy way to buttons at the bottom of the screen is to place them in a layout which would then be set to android:layout_alignParentBottom=”true”. 

If placed inside a container it enables them to exist ever if other content is trying to push them off. 

An example of this is: 

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

    <ListView
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <LinearLayout
        android:id="@+id/removeAllButtonLayoutAndCreateGroup"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum="4"
        android:layout_alignParentBottom="true">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Bye"
            android:id="@+id/byeText"
            android:textColor="@android:color/holo_red_dark"
            android:textSize="22sp"
            android:clickable="true"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="60dp"
            android:layout_gravity="right" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello"
            android:id="@+id/helloText"
            android:textColor="@android:color/black"
            android:textSize="22sp"
            android:clickable="true"
            android:layout_marginBottom="5dp"
            android:singleLine="false"
            android:layout_marginLeft="150dp" />

    </LinearLayout>

</RelativeLayout>

One thought on “Aligning buttons to the bottom/footer of the page easily Android

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s