I have the default seekbar
in my android app. I noticed that when the thumb
on the seekbar
is held, it turns yellow. Instead, I want it to turn blue when it is held. How can this be done? I apologize if this is a basic question, I am new to android development. Thanks.
Android supports it via xml. Just add android:thumbTint="@color/yourColor" in your seekbar.
If you are using default SeekBar provided by android Sdk then their is a simple way to change the color of that . just go to color. xml inside /res/values/colors. xml and change the colorAccent.
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.
A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys .
Use image filters to change color of default State List Drawables (including SeekBar):
// Change seekbar color to green. SeekBar sb = (SeekBar) findViewById(R.id.seekBar1); sb.getProgressDrawable().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY); sb.getThumb().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY);
The method getThumb
is only available since API 16+ (Jelly Bean).
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