一个简单的相对布局,与父权利对齐不起作用

Lee*_*fin 4 android android-widget android-emulator android-intent android-layout

我做了一个简单的相对布局,只包含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>
Run Code Online (Sandbox Code Playgroud)

我想将第二个TextView(id ="age")定位到右边,所以我使用layout_alignParentRight="true"它,但是它始终显示在第一个TextView(id ="name")之后,为什么?为什么它没有转到父权(最右边)?

Zel*_*ion 9

删除这个:

android:layout_toRightOf="@id/name"
Run Code Online (Sandbox Code Playgroud)

从年龄TextView