Change progressbar color through CODE ONLY in Android

前端 未结 12 1804
北海茫月
北海茫月 2020-12-01 01:12

I have a progressBar using the ProgressBar class.

Just doing this:

progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizont         


        
12条回答
  •  暖寄归人
    2020-12-01 01:45

    It is possible to colorize the Progress bar by setting the color filter on the progress bar drawable:

    Drawable drawable = progressBar.getProgressDrawable();
    drawable.setColorFilter(new LightingColorFilter(0xFF000000, customColorInt));
    

提交回复
热议问题