Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change colour of the thumb in seekbar?

Tags:

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.

like image 632
vergil corleone Avatar asked May 09 '13 20:05

vergil corleone


People also ask

How do I change my thumb SeekBar?

Android supports it via xml. Just add android:thumbTint="@color/yourColor" in your seekbar.

How do I change the color of my SeekBar track?

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.

How do I customize SeekBar?

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.

What is SeekBar thumb?

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 .


1 Answers

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).

like image 110
zavidovych Avatar answered Oct 12 '22 19:10

zavidovych