【问题标题】:Two RelativeLayouts, with the same height两个相对布局,高度相同
【发布时间】:2015-08-04 16:47:54
【问题描述】:

我有两个RelativeLayouts(一个并排)。
一个白色的RelativeLayout 和一个红色的。

随着白边文本数量的增加,我希望红边增加。

【问题讨论】:

  • 您需要发布您所拥有的 xml 并解释确切的问题。目前,您希望确切发生什么以及实际正在发生什么,这还不是很清楚。这类问题中的图片通常也很有帮助。
  • 我试图让你的问题更清楚。如果我无意中更改了含义,请随时回滚或编辑。

标签: android xml height android-relativelayout


【解决方案1】:

您是否尝试过将红色的 RelativeLayout android: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>

【讨论】:

  • 能不能先放红方?然后是白色的一面(带有编辑文本)?
  • 我给你改了一下,红边在前,白边在后。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多