I want semi circle progress bar in background of image. just like below image.
i have tried to draw using canvas but can't get success. i have also tired some custom progress bar library but result is same.
any suggestions.
looking for one time development and used in every screen size.
You may be able to use this github library - circularseekbar. To achieve the half circle, you will need to manipulate the following attributes: "app:start_angle" & "app:end_angle"
More Options:
You can try SeekArc Library. I know its a different kind of seekbar, but with some minor customization, you can use it for your app as a progressbar. I've done the same. You just need to change some properties like
seekarc:touchInside="false"
.Its fairly simple.
Now the custom implementation on my app looks somewhat like this:
img src: CleanMaster at Google Play
This can be implemented by clipping a canvas containing an image at an angle (By drawing an arc).
You can use an image something like this
And clip that image by drawing an arc.
Here is how you can do it.
And once you get the path, you can use
clipPath
function to clip the canvas in that path.Here is the Complete code
SemiCircleProgressBarView.java
And using it in any activity is very easy.
activity_main.xml
Note that
clipPath
function doesn't work if thehardware acceleration
is turned on. You can turn off the hardware acceleration only for that view.MainActivity.java
As and when the progress changes you can set the progressbar by calling function,
Ex:
semiCircleProgressBarView.setClipping(50); //50% progress
You can use your own Image to match the requirements. Hope it helps!!
Edit : To move the semi circle to bottom of the screen, change
mPivotY
value. Something like thisThis is a view which has height equal to half its width. Use the setters to adjust the behaviour as desired. By default the progress is 0 and the width of the arc is 20. Calling setProgress() will invalidate the view with the progress given. Adding a background drawable is possible and the progress bar will be draw on top.
You can also use native
ProgressBar
to achieve semi circle. DefineProgressBar
like this:Create drawable:
circular
(API Level < 21):circular
(API Level >= 21):useLevel
isfalse
by default in API Level 21.Now since we have set
max = 200
, to achieve semi circle, range of the progress should be0
to100
. You can play around with these values to achieve desired shape.Thus use it like this:
You can use this library :
for example :
For more information see the following website :
https://github.com/lzyzsd/CircleProgress