I am trying to change the hue of the Progress Bar without using a method setProgressTintList, as this method requires API 21.
For example, a button press should switch between these two modes:

My code is:
int[][] states = new int[][] {
new int[] { android.R.attr.state_enabled},
new int[] {-android.R.attr.state_enabled},
new int[] {-android.R.attr.state_checked},
new int[] { android.R.attr.state_pressed}
};
int[] colors = new int[] {
getResources().getColor(R.color.my_color),
getResources().getColor(R.color.my_color),
getResources().getColor(R.color.my_color),
getResources().getColor(R.color.my_color)
};
ColorStateList myList = new ColorStateList(states, colors);
ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.recording_progress);
simpleProgressBar.setProgressTintList(myList);
source
share