Pratik
Pratik

Reputation: 30855

Android: Is it possible to create such type of circle?

I google it but don't know about this which was possible or not to draw circle like this in android using canvas. If possible then how what the way to do this. below is the image.

I don't know any way to create circle in piece format using canvas

enter image description here

Upvotes: 1

Views: 168

Answers (3)

Nirav Ranpara
Nirav Ranpara

Reputation: 13785

Create 3 different Bipmap

hdip ldip mdip

instead of searching or XML

Upvotes: 0

Simon
Simon

Reputation: 14472

I can think of 3 options:

  1. Create it as a bitmap which you store in your Drawables or Assets then draw it to the canvas. You can scale it as needed when you load it or by scaling the canvas.

  2. You could draw a circle, then draw 3 lines in a different colour to create the "Y" shape, adjusting the thickness of the lines as you need (or use rectangles)

  3. Use an algorithm to calculate the segment then use drawPath to create the segments individually.

[EDIT] Doh! Elemental's solution is much better...

Upvotes: 1

Elemental
Elemental

Reputation: 7521

I believe that this is possible using Canvas.drawArc with the usecenter parameter set true.

take a look at the android docs

Upvotes: 1

Related Questions