商城类产品 在右上角添加状态的倾斜字体

这是需求  

需要自定义控件继承textview,一下是代码 
 
 
@SuppressLint("AppCompatCustomView")
public class RotateTextView  extends TextView {



    public RotateTextView(Context context) {
        super(context);
    }

    public RotateTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        //倾斜度45,上下左右居中
        canvas.rotate(45, getMeasuredWidth()/2, getMeasuredHeight()/2);
        super.onDraw(canvas);
    }
}
        


布局文件
  亲测有效具体布局适当调节

猜你喜欢

转载自blog.csdn.net/qq_22060403/article/details/80409150