11

私は単純なTextViewを持っています

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

Android 2.2.2 でテキストが 45 度回転しません。

色々なスレを見ましたが、みんなアニメやってます。アニメ化したくない。私が望むのは、テキストビューを回転させることだけです。

4

3 に答える 3

18

新しいビューのアンドロイドには、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);
}
于 2014-01-16T13:41:55.597 に答える