4

3 のみを含む単純な相対レイアウトTextViewを作成しました。コードは以下のとおりです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    > 

    <TextView 
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <!--Why this "age" TextView is not align to parent right?-->
    <TextView 
        android:id="@+id/age"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/name"
        android:layout_alignParentRight="true"/>

    <TextView 
        android:id="@+id/gender"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/name"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"/>

</RelativeLayout>

2 番目TextView(id="age") を右に配置したいので を使用しますlayout_alignParentRight="true"が、常に 1 番目TextView(id="name") の後に表示されるのはなぜですか? 親の右(一番右)に行かないのはなぜですか?

4

1 に答える 1

9

これを削除します:

android:layout_toRightOf="@id/name"

時代から TextView

于 2012-06-08T08:11:13.507 に答える