Search code examples
androidprocesscolorsstatusbarcycle

Android set cycle process bar color


How could I change color of cycle process bar? In Android 5, the default color is green but I would like to change it.

i am setting the background but it's not the right way since the whole space surrounding the progressbar will be colored.

progressBar.setBackgroundResource(drawable);

I also tried

progressBar.setProgressDrawable(drawable);

But it didn't response anything.

Do you guys have any idea? Thanks.


Solution

  • You can tint it with setColorFilter:

    progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.your_color), PorterDuff.Mode.SRC_IN);
    

    enter image description here