Reputation: 149
I am using the "normal" circle ProgressBar of Android which looks like this:
So, what I would like to do is to change the color, thickness and the corners (with cornerradius) of this ProgressBar.
I've found some examples for doing this stuff, but however it only was for horizontal ProgressBars, but I would like to keep this original ProgressBar.
Thank you very much!
Upvotes: 9
Views: 3661
Reputation: 22637
A progress bar is essentially a rotate
animation drawable. Here's something we use that is thinner with a different color gradient. You can see the use of thickness
for width and start
and end
color.
Tweak to your liking:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="720" >
<shape
android:shape="ring"
android:thickness="@dimen/progress_circle_thickness"
android:useLevel="false" >
<gradient
android:angle="0"
android:endColor="@color/progress_circle"
android:startColor="@android:color/transparent"
android:type="sweep"
android:useLevel="false" />
</shape>
</rotate>
and use in your layout something like this:
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminateDrawable="@drawable/progress_circle"/>
Upvotes: 10