Android的TextView的旋转,在API级别> = 8 [英] Android rotate TextView in API Level >= 8

查看:168
本文介绍了Android的TextView的旋转,在API级别> = 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有简单的TextView

I have simple TextView

<TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:rotation="45"
   android:text="Simple text" />

文字不会被旋转到45度在Android 2.2.2。

The text wont be rotated to 45 degree on Android 2.2.2.

我看到了不同的线程,但每个人都在做动画。我不想动画。我想要的是旋转的TextView。

I saw different threads, but everybody is doing an animation. I don't want to animate. All I want is to rotate the textview.

推荐答案

在Android的任何新的观点有一个叫方法的 setRotation(浮点)你可以用它

In android for any new view there is a method called setRotation(float) you can use it

textview.setRotation(float);

但请注意,这种方法被添加在API级别11

but please note that this method is Added in API level 11

所以,如果你想支持它,你可以使用这个

so if you want to support it you can use this

if (Build.VERSION.SDK_INT < 11) {

    RotateAnimation animation = new RotateAnimation(oldAngel, newAngel);
    animation.setDuration(100);
    animation.setFillAfter(true);
    textview.startAnimation(animation);
} else {

    textview.setRotation(progress);
}

这篇关于Android的TextView的旋转,在API级别&GT; = 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆