我有一个简单的TextView
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotation="45"
android:text="Simple text" />
在Android 2.2.2上,文字不会被旋转45度。
我看到了不同的线程,但每个人都在做动画。我不想进行动画,我只想旋转textview。
我有一个简单的TextView
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotation="45"
android:text="Simple text" />
在Android 2.2.2上,文字不会被旋转45度。
我看到了不同的线程,但每个人都在做动画。我不想进行动画,我只想旋转textview。
在Android中,对于任何新视图都有一个叫做setRotation(float)的方法,您可以使用它。
textview.setRotation(float);
但请注意,此方法是在API级别11中添加的。
因此,如果您想支持它,可以使用此方法。
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);
}