答案 0 :(得分:4)
我认为您可以通过绘制具有部分重叠的三条线来解决此问题:
Paint.Cap.ROUND
Paint.Cap.BUTT
假设您的输入数据是
float lineWidth = 20;
float lineRadius = 100;
float cornerRadius = 2;
你如下,
float width, radius;
// Draw outer lines
paint.setStrokeCap(Paint.Cap.ROUND);
width = cornerRadius * 2;
// Draw inner
radius = lineRadius - lineWidth/2f + cornerRadius;
canvas.draw(...)
// Draw outer
radius = lineRadius + lineWidth/2f - cornerRadius;
canvas.draw(...)
// Draw center
paint.setStrokeCap(Paint.Cap.BUTT);
width = lineWidth - 2f*cornerRadius;
radius = lineRadius;
canvas.draw(...)
您可能需要略微改变中心线的弧角(每侧必须cornerRadius
更长),但这很容易。