I have a progressBar using the ProgressBar class.
Just doing this:
progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
I need to change the color of that one, using input value like so:
int color = "red in RGB value".progressBar.setColor(color)
or something like that...
I can't use an XML layout because the progress bar is customizable for users.
Layout = activity_main.xml:
In Java Activity/Fragment:
The my_drawable_settings1.xml file inside your drawable/mipmap folder:
Where my_drawable_settings1 and my_drawable_settings2.xml has different colors.
I have given default color in xml by drawable.
I have changed it programatically.
activity_splasg.xml:
splash_progress_drawable.xml:
Now How to change ProgressDrawable color programatically.
Hope this will help you.
This post is what you're looking for: How to change progress bar's progress color in Android
If you want the user to choose their own colors, just make multiple-drawable XML files for each color, and select them based on the user's choice.
This works for me with AppCompat: DrawableCompat.setTint(progressBar.getProgressDrawable(), tintColor);
if you want to change color of progress bar programmatically then you copy past this code it is working 100%