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="htt开发者_如何学编程p://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>
When i upgraded my ADT, this problem solved itself. I think there was a bug on ADT's layout visual.
精彩评论