Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rotating a layout and after placing in relativeLayout prblem

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 .. enter image description here

like image 626
atasoyh Avatar asked Oct 11 '11 11:10

atasoyh


2 Answers

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.

like image 133
Hyque Avatar answered Nov 02 '22 18:11

Hyque


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>
like image 1
Pratik Popat Avatar answered Nov 02 '22 19:11

Pratik Popat