想做一个倾斜的TextView,想海报上显示的那样
首先需要先自定义一个TextView
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.peace.test.incline_textview.MyTextView
android:layout_width="100dip"
android:layout_height="100dip"
android:gravity="center"
android:text="@string/hello_world"/>