我正在尝试在自定义 View 中绘制此自定义形状。我必须对这个形状进行描边和填充。
rect.set(0, 0, width, height);
canvas.drawRoundRect(rect, cornerRadius, cornerRadius, paint);
path.moveTo(x, y);
...
path.close();
canvas.drawPath(path, paint);
如何使用Path用描边画出完整的形状,是真的吗?
最佳答案
为了描边你的路径,你应该在你为你的路径使用的油漆上设置描边:
val paint = Paint()
paint.style = Paint.Style.STROKE
paint.strokeWidth = BASE_STROKE_WIDTH
paint.isAntiAlias = true
paint.color = ContextCompat.getColor(context, R.color.your_color)
companion object {
const val BASE_STROKE_WIDTH = 20.0f
}
关于java - 在自定义 View 中绘制描边形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54900721/