Rotate layout and after placement in relativeLayout prblem

I need to rotate the layout (there are TextView and ImageView), and it needs to be placed to the right and top in the RelativeLayout. I create my layout, this layout is placed on the right. But if I rotate it, I cannot align it to the right. What should I do?

My relative layout

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

And I rotate this linearLayout with animation. It rotates well, ..

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

After turning a new visual ... enter image description here

+6
source share
3 answers

When I updated ADT, this problem resolved by itself. I think there was a bug in the visualization of ADT.

0
source

What version for Android are you using?

In newer versions, you can simply place landscape layouts in a special folder. Just create a new folder with the name " layout-earth " in your res / folder and place the layout for a landscape view in it. It should work well.

+1
source

This code works ...

use this

 <?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> 
+1
source

Source: https://habr.com/ru/post/899051/


All Articles