[英]Layout_below does not work in RelativeLayout
我是Android开发的新手。
我正在使用以下RelativeLayout。
我希望我的txtView1在lstAnswers之上,但是layout_below不起作用,并且视图被覆盖了。
<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"
android:background="#ffbad6e6"
tools:context="com.example.user.myApp.QuestionDetails">
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtView1"
android:textColor="#ff0d5e52"/>
<ListView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/lstAnswers"
android:layout_centerHorizontal="false"
android:paddingTop="50dp"
android:layout_alignParentTop="true"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:layout_below="@id/txtView1"/>
</RelativeLayout>
我还尝试使用@ + id设置layout_below,如下所示:
android:layout_below="@+id/txtView1"
但这什么也没给我。
谁能解释我如何在lstAnswers上方设置txtView1?
很容易。
从您的ListView中删除android:layout_alignParentTop="true"
。
因此, android:layout_below="@id/txtView1"
将能够完成其工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.