有没有人能建议我怎么用画布的方法画一个戒指。我可能会使用canvas.drawCircle()绘制圆圈,但是我应该如何感觉它们之间的空间呢?
发布于 2011-05-26 21:07:11
你可以用粗画笔画一个圆( setStrokeWidth).
发布于 2018-12-21 17:37:33
在kotlin中,您可以执行以下操作:
在init
中,使用笔划样式定义您的绘画
class CustomView(context: Context, attrs: AttributeSet) : View(context, attrs) {
private var ringPaint: Paint
init {
ringPaint = Paint()
ringPaint.color = R.color.RED // Your color here
ringPaint.style = Paint.Style.STROKE // This is the important line
ringPaint.strokeWidth = 20f // Your stroke width in pixels
}
}在onDraw方法中绘制圆
override fun draw(canvas: Canvas?) {
super.draw(canvas)
canvas?.drawCircle(width / 2.0f, height / 2.0f, (width - 10) / 2.0f, ringPaint)
}https://stackoverflow.com/questions/6138842
复制相似问题