1

enter image description here

I'm trying to draw this custom shape in the custom view. I must have a stroke and fill for this shape.

Now I made this with 2 shapes, but I haven't stroked of course: enter image description here

    rect.set(0, 0, width, height);
    canvas.drawRoundRect(rect, cornerRadius, cornerRadius, paint);
    path.moveTo(x, y);
    ...
    path.close();
    canvas.drawPath(path, paint);

How can I draw the full shape with stroke using Path, is it real?

Nicola Gallazzi
  • 7,897
  • 6
  • 45
  • 64
SWR
  • 73
  • 10

1 Answers1

1

In order to stroke your path you should set the stroke on the paint you're using for your 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
}
Nicola Gallazzi
  • 7,897
  • 6
  • 45
  • 64