How to make ProgressBar stop spinning?

I know that this is an old post but I ran into the same issue and I make it work.

It is actually easier than you think, you have to set a custom progress in an xml file inside your drawable folder and handle the attributes "fromDegrees" and "toDegrees" from the < rotate > tag:

This is the code for custom_progress.xml (you can customize yours as you like but you must not modify "fromDegrees" and "toDegrees")

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background">
        <shape
            android:innerRadiusRatio="2.3"
            android:shape="ring"
            android:useLevel="false"
            android:type="sweep"
            android:thicknessRatio="15.0">
            <solid android:color="#0099ff"/>
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <rotate
            android:pivotX="50%"
            android:pivotY="50%"
            android:fromDegrees="-90"
            android:toDegrees="-90">
            <shape
                android:innerRadiusRatio="2.3"
                android:shape="ring"
                android:angle="0"
                android:type="sweep"
                android:thicknessRatio="15.0">
                <solid android:color="#e0e0e0"/>
            </shape>
        </rotate>
    </item>
</layer-list>

And for your progress bar you have to set this attributes:

<ProgressBar
    android:id="@+id/progressbar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:indeterminate="false"
    android:max="100"
    android:progress="20"
    android:progressDrawable="@drawable/custom_progress" />

What is happening here is that the progress will start in degree -90 which for me is the top side of the progress bar view and towards the right and it will continue towards the same degree, this will make the view progress to start and end in the same degree.

NOTE: If you set 0 for both "fromDegrees" and "toDegrees" the progress will start from the right side of the circle.

Hope it helps people with the same requirement.


Since Api 21 you can do something like that: Assuming that your ProgressBar defind this way:

 <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
    style="?android:attr/progressBarStyleLarge"
    android:id="@+id/progress_bar"
    android:layout_width="@dimen/item_width"
    android:layout_height="@dimen/item_height"
    android:clickable="false"
    android:indeterminate="true"
    android:indeterminateDrawable="@drawable/progress"/>

and this is progress.xml:

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

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

    <gradient
        android:angle="0"
        android:endColor="@color/colorGrayText"
        android:startColor="@android:color/transparent"
        android:type="sweep"
        android:useLevel="false" />

</shape>

Now you can do this on your ProgressBar:

 ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
        if (progressBar != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                RotateDrawable rotateDrawable = (RotateDrawable) progressBar.getIndeterminateDrawable();
                rotateDrawable.setToDegrees(0);
            }
        }

Like toadzky commented, there's no baked-in method. You might try this ProgressWheel. If nothing else, it should give you idea of how to implement it.