How to change default ProgressBar circle color on Android

If you are using the AppCompat theme, it uses the accentColor to tint the circle.

If you want to tint it to a different color than the Theme, then you should consider using ThemeOverylay. E.g. If you want to make the circle tint red you could do the following:

in your styles.xml

<style name="RedAccent" parent="ThemeOverlay.AppCompat.Light">
    <item name="colorAccent">#F00</item>
</style>

in your ProgressBar, set the theme to be RedAccent.

<ProgressBar
            android:id="@+id/progress_bar"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:theme="@style/RedAccent"/>

And your circle will now be in red color!


Just add color in ProgressBar like below :

    <ProgressBar
    android:id="@+id/progressbar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:visibility="gone"
    android:indeterminateTint="@color/colorPrimary"  // add color here
    android:layout_centerVertical="true"/>

For future references, this change has worked for me is:

Changing the colorControlActivated within AppTheme in your values/styles.xml file:

 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Main theme colors -->
    ....
    <!-- Color for circle in progress bar -->
    <item name="colorControlActivated">#DC0808</item>
</style>

With this approach, you do not need to perform any action on your <ProgressBar/> tag within your xml file.


After several attempts I found a solution :

ProgressBar progBar = (ProgressBar) context.getActivity().findViewById(R.id.progress_bar);
if (progBar != null) {
    progBar.setVisibility(View.VISIBLE);
    progBar.setIndeterminate(true);
    progBar.getIndeterminateDrawable().setColorFilter(0xFFFFFFFF, android.graphics.PorterDuff.Mode.MULTIPLY);
}

Simply, i'll get a reference of the progress bar object created by the library and i change it's attributes. ( in my activity i must do that in a "OnStart" method otherwise it is null ) The most important part is the "setColorFilter" that do the magic.