<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg2x" >
<LinearLayout
android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_alignParentTop="true"
android:background="#FF00FF00"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:textSize="70dp"
android:text="test linearlayout"
/>
</LinearLayout>
Now I wanna Rotate the " linear " layout by 90 degrees. * And I dont wanna use Animation* , is there any other way to achive this? Please help me.Thanks in advance!!
Since you don't need animation, from API 11 or above, you can use
android:rotation = "90"
to rotate in XML itself. If you want to do it in code, say after a button click, then you can use its java equalant too
yourLayout = (LinearLayout) findViewById(R.id.your_id);
yourLayout.setRotation(90.0f);
But not before API 11. See documentation .
android:rotation
rotation of the view, in degrees.
Must be a floating point value, such as "1.2".
This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.
This corresponds to the global attribute resource symbol rotation.
yeah,I know this method in API level 11. But what about lower api level?
I think you can have to rotate the view yourselves. And I believe the lchorus and Pete's answer in this thread does work. For Pete's answer he is using animation, but you can set animation duration of 0 to do it without any visible animation. There is no other straight forward way as far as I know..
Using this library you can rotate whole view hierarchy https://github.com/rongi/rotate-layout
Like this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.