Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change android indeterminate ProgressBar color?

I would like to know how I can change indeterminate ProgressBar color from basis white/grey color to black ? When I change the indeterminateDrawable, I get a static image instead of a moving animated progressBar. Is there any way to do it simply in XML?

like image 681
mwa Avatar asked Apr 14 '10 14:04

mwa


People also ask

What is the default color of progress bar?

I'm using an horizontal progress bar in my Android application, and I want to change its progress color (which is Yellow by default).

What is indeterminate ProgressBar?

Android ProgressBar Indeterminate ProgressBar An indeterminate ProgressBar shows a cyclic animation without an indication of progress.


2 Answers

progressBar.getIndeterminateDrawable().setColorFilter(             getResources().getColor(Your_Color),             android.graphics.PorterDuff.Mode.SRC_IN); 

and replace Your_Color with the desired color like: R.color.your_color_code

like image 130
Zeyad Assem Avatar answered Oct 05 '22 04:10

Zeyad Assem


To get a ProgressBar in the default theme that is to be used on white/light back ground, use one of the inverse styles:

<ProgressBar style="@android:style/Widget.ProgressBar.Inverse"/> <ProgressBar style="@android:style/Widget.ProgressBar.Large.Inverse"/> <ProgressBar style="@android:style/Widget.ProgressBar.Small.Inverse"/> 

This will usually give you a black on transparent ProgressBar, but some OS installs use custom assets. If you're looking for a specific color, you'll have to roll your own drawables by following the instructions provided by CommonsWare.

like image 44
Anm Avatar answered Oct 05 '22 03:10

Anm