I'm new to the layout structure in android and I'm tasked with building an activity that has a button at the bottom (centered horiz as well) with a small bit of padding between the bottom of the button and the bottom of the visible screen.
The challenge is how to do this in relative layout and make it anchor to the same spot regardless of screen size
If anyone can point me in the right direction that would be great!
The dev docs have some sample layouts and the API Demos project is great too.
The layout below will put the button at the bottom, but remember as you add more controls to a relative layout they will have to respect each other. like layout_above this button or put this button at the end and make sure it has an attribute like android:layout_below="id_of_other_bottommost_controll"
<?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" >
<Button
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:text="button"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With