Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A simple Relative layout, align to parent right not work

I have made a simple relative layout which only contains 3 TextView , code is below:

<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>

I would like the 2nd TextView(id="age") to be positioned to right, so I use layout_alignParentRight="true", however, it always show after the 1st TextView(id="name"), why? Why it does not go to the parent right (rightmost) ?

like image 268
Leem.fin Avatar asked Jan 16 '23 11:01

Leem.fin


1 Answers

remove this:

android:layout_toRightOf="@id/name"

from the age TextView

like image 185
Zelleriation Avatar answered Jan 19 '23 02:01

Zelleriation