Jumpa Jumpa - 2 months ago 30
Android Question

Lollipop Progress Bar Tinting

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

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