[英]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.