I need to rotate a layout( has a TextView and ImageView) and it should be placed align right and top in RelativeLayout. I create my layout, this layout is placed right-top. But if i rotate it i cant align 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. This rotates good,..
<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 Rotate new visial is ..
What android version are you using?
In newer versions it is possible to simply put landscape layouts into a special folder. Just create a new folder named "layout-land" in your res/ folder and put your layout for landscape view into it. It should work well.
This Code Is working ...
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With