Lollipop Progress Bar Tinting

Jumpa picture Jumpa · Jun 24, 2015 · Viewed 23.7k times · Source

I'm on a Lollipop device (MotoG 2014), I read about progress bar tinting, but this is not working...I get the default progress bar color. What am I missing here?

<ProgressBar
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:backgroundTintMode="src_in"
    android:indeterminate="true"
    android:indeterminateTint="#f00" />

Many thanks.

Answer

Skizo-ozᴉʞS picture Skizo-ozᴉʞS · Jun 24, 2015

Try changing your ProgressBar to this

<ProgressBar
android:id="@+id/view_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="50dp"
android:layout_height="50dp"
android:indeterminate="true"
android:indeterminateTintMode="src_in"
android:indeterminateTint="@color/red"
/>

Also you can do it programmaticaly doing this :

ProgressBar progressBar;
progressBar = (ProgressBar)findViewById(R.id.view_progress);
progressBar.getProgressDrawable().setColorFilter(Color.RED, Mode.SRC_IN);

References

Setting in ProgressBar Tint color