In a RelativeLayout
if a view has android:layout_alignParentBottom="true”
then it is placed to the bottom of the parent.
If 2 views have android:layout_alignParentBottom="true”
then both are placed on the bottom, but 1 above the other.
How can I have 2 view to have the setting android:layout_alignParentBottom="true”
and one to be stacked over the other?
android:layout_above
seems to be not applicable/working for this case.
Put the views inside a LinearLayout with orientation - vertical
, and put
layout_alignParentBottom=true
To the LinearLayout;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:background="@color/black"
android:layout_height="match_parent">
<LinearLayout
android:layout_alignParentBottom="true"
android:background="@color/red"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>