How to snap button at bottom of relative layout in android

I am new to the layout structure in android, and I am tasked with creating an action in which there is a button at the bottom (centered in the horizontal direction) with a slight indentation between the bottom of the button and the bottom of the visible screen.

The challenge is how to do this in a relative layout and make it snapped to the same place regardless of screen size

If someone can point me in the right direction, that would be great!

+5
source share
2 answers

dev docs have some sample layouts and the Demos API is a great project.

, , , . layout_above , , 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>
+10

. "Layout align parent bottom" "Layout center horizontal". , , .

0

All Articles