Relativelayout没有包装其内容

Bil*_*der 5 xml android android-layout android-relativelayout android-wrap-content

我希望我的内心RelativeLayout包装它的内容并保持在View元素之下.为什么它不像下面的图片?

我的layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <View
        android:id="@+id/linearLayout"
        android:layout_above="@+id/input_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <RelativeLayout
        android:id="@+id/input_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#ebebeb">

        <EditText
            android:id="@+id/editText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_toLeftOf="@+id/imageView13"
            android:layout_toStartOf="@+id/imageView13"
            android:background="@android:color/white"
            android:padding="8dp" />

        <ImageView
            android:id="@+id/imageView13"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:src="@drawable/ic_m_send" />

    </RelativeLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Rav*_*avi 10

android:layout_alignParentBottom="true"从你的两个删除EditText,ImageView将解决你的问题.

RelativeLayout已经拥有了android:layout_alignParentBottom="true",如果你为它的孩子设置相同,它也会将布局高度设置为全屏.

请注意,RelativeLayout的大小与其子项的位置之间不能存在循环依赖关系.例如,您不能将RelativeLayout的高度设置为WRAP_CONTENT,将子级设置为ALIGN_PARENT_BOTTOM

班级文件