I am trying to add two colors in progress bar. in my project there is a button called "increase". When I press increase and holds it then the progress bar increases with yellow color, now what I am trying is that when I release "increase" button the progress bar should add a small bar with green color.
My problem is that when I release the button then whole progress bar is getting filled by green color instead of yellow color till I hold the button and a small bar at releasing the button.
I am attaching the screenshot.
below is the code snippet
if (i == 0) {
progressBar1.setProgress(progressBar1.getProgress() + 10);
progressBar1.setProgressDrawable(getResources().getDrawable(
R.drawable.progress_layer));
i = 1;
} else {
progressBar1.setProgress(progressBar1.getProgress() + 1);
progressBar1.setProgressDrawable(getResources().getDrawable(
R.drawable.progress_layer_normal));
}
Here i is 0 by default when I tap and holds the button progress bar increase with yellow color. now when I release the button i becomes 1 and green color bar should be added to the progress bar. but the whole progress bar becomes green.
It is impossible to achieve that with the standard ProgressBar.
You should consider creating the custom view from scratch.
You can start here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With