当我在最后一个EditText(opedt)中键入长文本时,它与底部的按钮重叠。文本位于按钮顶部。我希望文本在到达按钮之前停止并滚动。怎么去呢?
这是我的布局文件:
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="mpack.gt.UnityActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/finirbtn"
android:background="#008000"
android:id="@+id/validerreponsebtn"
android:layout_alignParentBottom="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/opmtxt"
android:textSize="20sp"
android:textStyle="bold"
android:id="@+id/opmtxt"
android:layout_alignParentTop="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/opdesc"
android:layout_below="@+id/opmtxt"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/repopmstxt"
android:textSize="20sp"
android:textStyle="bold"
android:id="@+id/repopmtxt"
android:layout_below="@+id/opdesc"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/opreponseedt"
android:layout_below="@+id/repopmtxt"
android:hint="@string/hintreponse"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
答案 0 :(得分:0)
如果要防止元素重叠,则不应首先使用RelativeLayout
,而是选择不允许子视图重叠的其他布局。 RelativeLayout
允许你这样做,所以当文本视图增长时,它不会像LinearLayout
那样扩展(除非孩子需要更多的空间来完成整个布局)
答案 1 :(得分:0)
一种方法是将Button
设置在最后一个EditText下方,而不是对齐到底部。
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/finirbtn"
android:background="#008000"
android:id="@+id/opreponseedt"
android:layout_below="@+id/opdesc"/>