android"layout_alignParentBottom"的相对布局

Bud*_*ril 10 android alignment android-relativelayout

所以,我有这个布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/layout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#FFFF00"
                android:minHeight="100dp"
                android:layout_gravity="bottom"
        >
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textColor="#000000"
            android:background="#FF0000"
            android:text="Hello World"
            />

    <Button
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_alignParentRight="true"
            android:text="button"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这就是它的样子:

在此输入图像描述

但如果我android:layout_alignParentBottom="true"在这里添加按钮是它的样子:

在此输入图像描述

  1. 有人可以解释一下这种行为吗?
  2. 如何在没有调整黄色布局大小的情况下将我的按钮放在底部而不添加数千种布局来进行解决方法?

Bud*_*ril 8

这个解决方案对我有用

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/layout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#FFFF00"
                android:minHeight="100dp"
                android:orientation="horizontal"
                android:layout_gravity="bottom"
        >
    <TextView
            android:id="@+id/tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:textColor="#000000"
            android:background="#FF0000"
            android:text="Hello World"
            />

    <Button
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_gravity="bottom|right"
            android:text="button"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)