我希望内部的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>

android - 相对布局未包装其内容-LMLPHP

最佳答案

从您的android:layout_alignParentBottom="true"EditText中删除ImageView将解决您的问题。

您的RelativeLayout已经具有android:layout_alignParentBottom="true",并且如果将其设置为子代,则还将布局高度设置为全屏。



Class Document

10-07 19:05
查看更多