如何将 2 个视图放置在父级的底部,但一个堆叠在另一个之上?

How to place 2 views to the bottom of the parent but one stacked above the other?

RelativeLayout 中,如果一个视图有 android:layout_alignParentBottom="true”,那么它将被放置到父视图的底部。
如果 2 个视图有 android:layout_alignParentBottom="true”,则两个视图都放在底部,但 1 个 在另一个 上方。
我怎样才能让 2 个视图具有设置 android:layout_alignParentBottom="true” 并且一个视图堆叠在另一个视图之上?
对于这种情况,android:layout_above 似乎不是 applicable/working。

如果只设置android:layout_alignParentBottom="true”,则不会依次放置。请粘贴您的布局 xml 以便找到真正的问题。

layout_above 表示 Y 方向 "above",而不是 Z 方向,如果这有意义的话。如果您希望它们叠加,请删除 layout_above 属性并将它们都设置为 layout_alignParentBottom=true.

将视图放入带有 orientation - vertical 的 LinearLayout 中,然后放入

layout_alignParentBottom=true

到线性布局;

<?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>