Android的:如何旋转的LinearLayout [英] Android:How to rotate LinearLayout
问题描述
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / RelativeLayout1
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@可绘制/ bg2x>
<的LinearLayout
机器人:ID =@ + ID /线性
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直
机器人:重力=中心
机器人:layout_alignParentTop =真
机器人:后台=#FF00FF00
>
<的TextView
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#FF000000
机器人:TEXTSIZE =70dp
机器人:文本=测试的LinearLayout
/>
< / LinearLayout中>
现在我想的旋转的线性90度布局。 *而我不想用动画* ,在那里才达到这种任何其他方式? 请帮助提前me.Thanks !!
既然你不需要动画,从API 11或以上,你可以使用
机器人:旋转=90
在XML本身旋转。如果你想这样做在code,之后点击一个按钮说,那么你可以使用它的Java equalant太
yourLayout =(的LinearLayout)findViewById(R.id.your_id);
yourLayout.setRotation(90.0f);
但并不是API 11参见<前href="http://developer.android.com/reference/android/view/View.html#attr_android%3arotation">documentation.
机器人:旋转
的视图,以度的旋转。
必须是一个浮点值,例如1.2。
这也可能是一个参考的资源(在表格 @ [包:]类型:名称)或主题属性(形式 [包:] [类型:]名。)含有这种类型的值
这对应于全局属性资源的符号旋转
编辑:看到评论后
是的,我知道这个方法在API层面11.但对于较低的空气污染 水平如何?
我觉得你可以旋转视图自己。而且我相信lchorus和这线程执行的工作。对于皮特的回答,他是用动画,但您可以设置为0动画的时间做到这一点没有任何明显的动画。有没有其他的直接的方式,据我知道..
<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.
EDIT: After seeing comment
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..
这篇关于Android的:如何旋转的LinearLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!