I want to draw a shape as defined using Path with a stroke width of 5 where all of the stroke is inside the Path rather than half the stroke inside and half outside.
Thanks,
Carl
Sometimes you want an outline around your shape and to do that you can use the stroke tag. You can specify the width and color of the outline using android:width and android:color.
The stroke-width attribute is a presentation attribute defining the width of the stroke to be applied to the shape.
It seems it can not control the position of the stroke (i.e, inside, center or outside). For more info refer to: Android Paint stroke width positioning
My solution is offset the stroke width while drawing e.g.,
final RectF rectF = new RectF(halfStrokeWidth, halfStrokeWidth, width - halfStrokeWidth, height - halfStrokeWidth);
canvas.drawRoundRect(rectF, roundX, roundY, paint);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With