4

I need to make an indeterminate progress bar that is identical to the default widget just in a different color. I can't use tinting because I need to support from api 15+.

My solution thus far is to use a custom drawable xml:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
    android:toDegrees="360">

    <shape android:shape="ring" android:innerRadiusRatio="3"
        android:thicknessRatio="8" android:useLevel="false">

        <size android:width="48dip" android:height="48dip" />

        <gradient android:type="sweep" android:useLevel="false"
            android:startColor="somecolor" android:centerColor="somecolor"
            android:centerY="0.50" android:endColor="somecolor" />

    </shape>

</rotate> 

and then define that custom drawable thusly:

        <ProgressBar
        android:id="@+id/customprogressbar"
        android:layout_width="42dp"
        android:layout_height="35dp"
        android:layout_gravity="center"
        android:visibility="gone"
        android:indeterminateDrawable="@drawable/customprogressbardrawable"
        style="@android:style/Widget.ProgressBar"
        />

This works, but it doesn't look like the default progressbar. What are the default settings that I can use - or is there a better way to make my progressbar identical in every way with the default widget, just in different colors?

Jon
  • 7,941
  • 9
  • 53
  • 105
  • 1
    [this](http://stackoverflow.com/questions/26814798/how-to-implement-a-material-design-circular-progress-bar-in-android) might help you – Rahul Tiwari Oct 01 '15 at 14:01
  • Not a duplicate... Whoever marked it as duplicate mustn't have seen the part "because I need to support from api 15+" – Jake Aug 08 '19 at 06:42

1 Answers1

3

Thanks for your replies. For anyone whose interested, I solved it in the end with this 3rd party library:

https://github.com/DreaminginCodeZH/MaterialProgressBar

Jon
  • 7,941
  • 9
  • 53
  • 105