I am working with custom view which is in a circle shape. Almost i have done it with creating a custom class and implemented that. But my problem is too show a different progress in a curve shape with different color and which is depends on dynamic data. Here is the image which i have implemented
I want like this http://imgur.com/cmNKWBF.
So my question is how to draw arc (curve shape) progress with different color and with dynamic data.
Help would be appreciated !!
Finally i have resolved this after making some changes in Custom
CircleView
class. For that i have counted asweepAngle
andstartAngle
for each region. Here is some part of code i am posting.I had to show three different regions so i have taken three different
Paints
and declared variable for each regions. Like,Now init your all three regions paints. Here i just posting one of them
Now to calculate the area of each region i had created a method named
updateAngles()
which have three float parametersThis method will be called in your desired activity after initialize
CircleView
and call likecv.updateAngles(20,20,60);
wherecv
is object ofCircleView
.Now in
onDraw()
method you need to draw arc for each region.So this finally giving me a my desired output.
But if there is depend on different devices like mobile screen , 7 inch and 10 inch tablets then you should use
DisplayMetrics
for it.Below code satisfies your requirement.