How can I change the color of a horizontal progress bar programmatically without creating a custom drawable?
I tried using this code from another question
progressBar.getProgressDrawable().setColorFilter(Color.RED, Mode.SRC_IN);
but that does not fix it, as the entire progress bar goes red. In the comments there was one user saying to use Mode.MULTIPLY
but the entire progress bar just goes black. I also tried using SRC_ATOP
without success.
My ProgressBar is defined as follows:
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal" />
Is there any other way to solve this without using custom drawables?