【问题标题】:A simple Relative layout, align to parent right not work一个简单的相对布局,与父右对齐不起作用
【发布时间】:2012-06-12 07:09:13
【问题描述】:

我做了一个简单的相对布局,它只包含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>

我希望将第二个TextView(id="age") 定位在右侧,所以我使用layout_alignParentRight="true",但是它总是显示在第一个TextView(id="name") 之后,为什么?为什么它不去父右边(最右边)?

【问题讨论】:

    标签: android android-layout android-intent android-emulator android-widget


    【解决方案1】:

    删除这个:

    android:layout_toRightOf="@id/name"
    

    来自TextView的时代

    【讨论】:

      猜你喜欢
      • 2016-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-08
      • 2012-06-11
      • 1970-01-01
      相关资源
      最近更新 更多