0
点赞
收藏
分享

微信扫一扫

安卓实现文字(TextView)旋转,包括文字角标

文风起武 2022-02-27 阅读 77
android2dgit


实现方案

通过TextView的rotation属性设置旋转角度并实现文字角标.


  • 效果图
    安卓实现文字(TextView)旋转,包括文字角标_2d
  • 代码

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:layout_margin="30dp"
android:rotation="45"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:layout_margin="30dp"
android:rotation="90"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:layout_margin="30dp"
android:rotation="-45"/>

<RelativeLayout
android:layout_width="60dp"
android:layout_height="60dp"
android:background="@drawable/shape_rec_blue">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:layout_marginRight="-20dp"
android:background="#FA871E"
android:gravity="center"
android:paddingLeft="20dp"
android:paddingTop="2dp"
android:paddingRight="20dp"
android:paddingBottom="2dp"
android:rotation="45"
android:text="Hello"
android:textColor="#FFFFFF"
android:textSize="12sp"/>
</RelativeLayout>

Demo源代码

https://github.com/cxyzy1/textViewDemos.git



举报

相关推荐

0 条评论