2011-10-12 52 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