當我在RelativeLayout中使用'textA','textB'和'textC'聲明3個TextView時。 textC應該出現在textB下面。但是運行時,textC顯示位置不正確(位於屏幕的左上角)。 我不知道textC可以使用android:layout_below來textB。無法在RelativeLayout中定義TextView位置
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent" >
<TextView
android:id="@+id/textA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:text="This is TextA : " />
<TextView
android:id="@+id/textB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/textA"
android:layout_alignBaseline="@id/textA"
android:text="this is textB" />
<TextView
android:id="@+id/textC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/textB"
android:text="This is TextC" />
</RelativeLayout>
我只知道alignBaseline應該避免這種情況。所以對其他元素使用相對位置就是解決這個問題的方法。 – user1953029