2011-10-11 28 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>