Soheil
Soheil

Reputation: 1706

Drawing half of a ring in Android

I need to draw half of a ring via XML (or Java code). I searched but I only understood that that is not possible via XML but I didn't find any more hint. How could I do that?

Upvotes: 1

Views: 1132

Answers (1)

JagrDev
JagrDev

Reputation: 107

Use Paint.Style.STROKE for your Paint to draw a ring and canvas.drawArc for a part of the ring:

Paint paintRing = new Paint(Paint.ANTI_ALIAS_FLAG);
paintRing.setColor(Color.argb(255, 100, 100, 100));
paintRing.setStrokeWidth(10);
paintRing.setStyle(Paint.Style.STROKE);

...

RectF ring = new RectF(0f,0f,100f,100f);
canvas.drawArc(ring, 0, 180, false, paintRing);

Upvotes: 2

Related Questions