两个 RelativeLayouts,具有相同的高度
Two RelativeLayouts, with the same height
我有两个 RelativeLayout
(一个挨着一个)。
一个白色的RelativeLayout
和一个红色的
随着白色部分的文本量增加,我希望红色部分增加。
你试过把红色的RelativeLayoutandroid:layout_alignBottom设置成白色的RelativeLayout的id吗?
我不确定您的文本是如何输入到白色布局中的,但是如果您正在处理白色 RelativeLayout 内部的 EditText,那么这应该确保红色的一面始终与白色的高度相同随着新文本的添加导致白边的高度增加。
大致如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<RelativeLayout
android:id="@+id/red"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/white"
android:background="#FF0000">
</RelativeLayout>
<RelativeLayout
android:id="@+id/white"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/red"
android:layout_toRightOf="@id/red"
android:background="#FFFFFF">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="false"
/>
</RelativeLayout>
</RelativeLayout>
我有两个 RelativeLayout
(一个挨着一个)。
一个白色的RelativeLayout
和一个红色的
随着白色部分的文本量增加,我希望红色部分增加。
你试过把红色的RelativeLayoutandroid:layout_alignBottom设置成白色的RelativeLayout的id吗?
我不确定您的文本是如何输入到白色布局中的,但是如果您正在处理白色 RelativeLayout 内部的 EditText,那么这应该确保红色的一面始终与白色的高度相同随着新文本的添加导致白边的高度增加。
大致如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<RelativeLayout
android:id="@+id/red"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/white"
android:background="#FF0000">
</RelativeLayout>
<RelativeLayout
android:id="@+id/white"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/red"
android:layout_toRightOf="@id/red"
android:background="#FFFFFF">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="false"
/>
</RelativeLayout>
</RelativeLayout>