如何TextView的旋转90度,显示TextView

2023-09-12 22:51:47 作者:葬你眉目

我有一种情况,图形页面,在这里的LinearLayout应显示为90度的旋转的TextView

i am having a situation in Graph page where LinearLayout should display the TextView with 90 Degrees rotated.

希望我的问题是清楚的,如果不是请让我知道。

Hope my question is clear if not please let me know.

推荐答案

最快,最方便的方法就是旋转动画

The fastest and most convenient way is to Rotate by Animation

使用旋转动画在你的常规的TextView像这样。

use rotate animation on your regular TextView like so.

rotateAnimation.xml:

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的code:

Java Code:

  TextView text = (TextView)findViewById(R.id.txtview);       
  text.setText("rotated text here");

  RotateAnimation rotate= (RotateAnimation)AnimationUtils.loadAnimation(this,R.anim.rotateAnimation);
  text.setAnimation(rotate);
 
精彩推荐
图片推荐