android中文字斜着显示

/** * 自定义一个Textview * * @author Administrator * */ public class MyTextView extends TextView { public MyTextView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onDraw(Canvas canvas) { // 倾斜度45,上下左右居中 canvas.rotate(-45, getMeasuredWidth() / 2, getMeasuredHeight() / 2); super.onDraw(canvas); } }
//xml文件中添加上这个MyTextView 
<com.xhm.test.incline_textview.MyTextView
        android:layout_width="100dip"
        android:layout_height="100dip"
        android:gravity="center"
        android:text="@string/hello_world"/>

 

相关文章:

  • 2022-03-10
  • 2021-12-21
  • 2021-06-09
  • 2022-12-23
  • 2022-02-18
  • 2021-12-02
猜你喜欢
  • 2021-04-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
相关资源
相似解决方案