2011-10-11 58 views
6

我需要旋轉一個佈局(有一個TextView和ImageView),它應該放置在RelativeLayout右對齊和頂部。我創建了我的佈局,這個佈局放在右上角。但是,如果我旋轉它,我不能對齊。我該怎麼辦?旋轉一個佈局,並放置在relativeLayout項目

我相對佈局

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

       <ImageView 
         android:layout_height="wrap_content" 
         android:layout_width="wrap_content" 
         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:layout_centerInParent="true" 
         android:textColor="@android:color/white" 
         android:id="@+id/amountLayoutTV" /> 
     </RelativeLayout> 
</RelativeLayout> 

我旋轉這個的LinearLayout動畫。這種旋轉好,..

<rotate 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:fromDegrees="0" 
     android:toDegrees="45" 
     android:pivotX="50%" 
     android:pivotY="50%" 
     android:fillEnabled="true" 
     android:detachWallpaper="true" 
     android:duration="0" 
     android:fillAfter="true"> 
</rotate> 

後旋轉的新visial是.. enter image description here

回答

0

當我升級我的ADT,這個問題解決了自身。我認爲ADT的佈局視覺上存在一個錯誤。

1

什麼Android版本您使用的?

在新版本中,可以簡單地將橫向佈局放入特殊文件夾中。 只需在res /文件夾中創建一個名爲「layout-land」的新文件夾,並將橫向視圖的佈局放入其中。它應該運作良好。

1

此代碼的工作...

使用本

<?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/normal_button" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center" 
     android:id="@+id/testRL"> 

     <RelativeLayout 
       android:layout_width="100dp" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:background="@drawable/pressed_button" 
       android:id="@+id/testRotateLL"> 

       <TextView 
        android:id="@+id/amountLayoutTV" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentTop="true" 

        android:text="7000TL" 
        android:textColor="@android:color/white" 
        android:textSize="15sp" /> 

     </RelativeLayout> 
</RelativeLayout>