I want to create a custom seekbar, whose progress bar's colour change between red and blue as the user changes the progress of the bar.
I have tried it but its only changing the background colour not the progress bar color.
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
seekBar.setBackgroundColor(Color.RED + progress);
}
});
To change the circular progress indicator color globally, you can use the ColorScheme class. It's a group of 25 colors based on the Material 3 design. Using the ColorScheme class you can define the colors for your app.
You need to call setLevel on the ClipDrawable. It takes a value from 0 to 10000. So, progress. setLevel(2500) would be 25% full.
Now go to the activity_main. xml create a layout and inside the layout add a SeekBar. Specify the height width of SeekBar and the max progress that you want to use set progress to 0. This will create a customized Seekbar inside activity_main.
There are a lot of way to do this, I'll tell the simple way. You can set the color of progressBackground like this:
seekBar.getProgressDrawable().setColorFilter("<Color you wish>", PorterDuff.Mode.MULTIPLY);
If your api level 21, you can use getProgressBackgroundTintList or getProgressBackgroundTintMode().
use custom seek bar for that requirement see following link's
http://www.mokasocial.com/2011/02/create-a-custom-styled-ui-slider-seekbar-in-android/
Seek bar, change path color from yellow to white
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