两个或多个嵌套的RelativeLayout

ata*_*oyh 9 android relativelayout android-layout

我想问一下,使用两个或多个嵌套的RelativeLayout.第一个代码看起来像图片1,当我添加android:layout_alignParentRight="true"第二个RelativeLayout时,这看起来像图片2.我想将文本对齐到第二个RelativeLayout.我的错在哪里?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:background="@drawable/background"
        android:layout_height="wrap_content"
        android:id="@+id/testRL">
        <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:id="@+id/testRotateLL"
                android:background="@drawable/picture_border_offer_first_page">
                <TextView
                        android:layout_height="wrap_content"
                        android:layout_width="wrap_content"
                        android:text="7000TL"
                        android:textSize="15sp"
                        android:textColor="@android:color/white"
                        android:id="@+id/amountLayoutTV" />
        </RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

图片1:

图片1

我补充说 android:layout_alignParentRight="true"

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:background="@drawable/background"
    android:layout_height="wrap_content"
    android:id="@+id/testRL">
    <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:id="@+id/testRotateLL"
            android:background="@drawable/picture_border_offer_first_page">
            <TextView
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:text="7000TL"
                    android:layout_alignParentRight="true"
                    android:textSize="15sp"
                    android:textColor="@android:color/white"
                    android:id="@+id/amountLayoutTV" />
    </RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

图2:

图2

ata*_*oyh 4

这个问题没有答案。当我更新ADT版本后,这个问题就解决了。我认为有一个错误。

我建议你有时检查一下ADT的版本...

  • 还有另一个提示,不要总是更新你的 ADT 版本!因为新版本会带来新的错误!您应该始终在另一个 Eclipse IDE 上测试 adt。 (2认同)