2011-10-12 53 views
9

我想问,使用两个或更多嵌套的RelativeLayout。 第一个代码看起来像图片1,当我在第二个RelativeLayout中添加android:layout_alignParentRight="true"时,这看起来像图片2.我想将文本右对齐到第二个RelativeLayout。哪里是我的错吗?两个或更多嵌套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> 

图片1:

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

图2:

Picture 2

+0

尝试添加到''TextView'机器人:layout_alignParentTop = “真正的”' –

+0

最坏的情况:前'TextView'添加'ImageView'代替'android:background =“@ drawable/picture_border_offer_first_page”'。他们将覆盖 –

+0

@首先我试着alightTop,它的一样。 – atasoyh

回答

4

这个问题没有答案。当我更新ADT版本时,解决了这个问题。我想,有一个错误。

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

+2

也是另一个提示,并不总是更新您的ADT版! ,因为更新的版本带有更新的错误!你应该总是在另一个Eclipse IDE上测试adt。 – meh

+0

@meh - 是的,你说得对。 – atasoyh

0

在第一RelativeLayout的你:

android:layout_width="wrap_content" 
android:layout_height="wrap_content" 

你可能想:

android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
+0

我试过了,另外我的背景图像足够大... – atasoyh