我有一个在图形页面的情况下,LinearLayout
应该显示90度旋转的TextView
。
发布于 2012-01-22 14:24:56
最快、最方便的方法是通过Animation
执行Rotate
在常规TextView上使用旋转动画,如下所示。
rotateAnimation.xml:
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="-90"
android:pivotX="50%"
android:duration="0"
android:fillAfter="true" />
Java代码:
TextView text = (TextView)findViewById(R.id.txtview);
text.setText("rotated text here");
RotateAnimation rotate= (RotateAnimation)AnimationUtils.loadAnimation(this,R.anim.rotateAnimation);
text.setAnimation(rotate);
发布于 2015-04-29 17:51:17
试试这个::
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:rotation="-95"
android:text="2"
/>
发布于 2014-01-14 17:46:37
在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);
watermarkText.startAnimation(animation);
} else {
watermarkText.setRotation(progress);
}
https://stackoverflow.com/questions/8959069
复制相似问题