2011-10-11 5 views
6

Necesito rotar un diseño (tiene un TextView e ImageView) y debe colocarse alineado a la derecha y arriba en RelativeLayout. Creo mi diseño, este diseño se coloca en la parte superior derecha. Pero si giro, no puedo alinear bien. ¿Que debería hacer?rotando un diseño y después de colocarlo en relativaDisposición de problema

Mi disposición relativa

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

Y gire este LinearLayout con la animación. Esto hace girar buena, ..

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

Después Girar nueva visial es .. enter image description here

Respuesta

0

cuando actualicé mi ADT, este problema se resolvió solo. Creo que hubo un error en el diseño visual de ADT.

1

¿Qué versión de Android está usando?

En las versiones más recientes, es posible simplemente colocar diseños de paisajes en una carpeta especial. Simplemente cree una nueva carpeta llamada "layout-land" en su carpeta/res y ponga su diseño para la vista horizontal en ella. Debería funcionar bien.

1

Este código está trabajando ...

uso de este

<?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> 
Cuestiones relacionadas