2018.11.26
class RoundTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet ?= null, defStyle: Int = 0):
androidx.appcompat.widget.AppCompatTextView(context, attrs, defStyle){
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
val paint = Paint()
paint.color = Color.RED
paint.strokeWidth = 2f
paint.style = Paint.Style.STROKE
paint.isAntiAlias = true
val rectF = RectF(1f, 1f, (this.width-1).toFloat(), (this.height-1).toFloat())
canvas.drawRoundRect(rectF, 10f, 10f, paint)
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/aec4047e3f76e89ba194aa2e52ef5bef.jpeg#pic_center)