I have the following custom view:
This I have achieved by using the Canvas' drawArc()
method. However, with this drawArc()
method I cannot limit the arc's inner radius.
What I'd like to have is something like this:
where there is only an outer ring left.
What I need is an drawArc()
function where I can set the inner radius of the arc. Anyone an idea how to do that?
(BTW, overpainting the inner area doesn't work, because it needs to be transparent. Painting an inner circle with Color.TRANSPARENT
after painting the red and blue cones doesn't remove the old color. It just puts another layer on top, which is transparent and through which I can still see the red and blue)
You can do this:
The key is in
paint.setStyle(Paint.Style.STROKE);
, it crops the arc's center with the stroke that you define in setStrokeWidth (in the example draws an arc with a radius of mRadius and 20px thick).Hope it helps!
You can try following ShapeDrawable
drawing Circle and Arc. the following code is little dirty but it may help
Can be extended to oval arc by duplicating
rInn
andrOut
for x and y directions.Also wasn't part of the question, but to draw a text in the middle of a segment:
You can paint over the inner area using the PorterDuff xfermode called "Clear." This will erase pixels.