How to change colour of the thumb in seekbar?

vergil corleone picture vergil corleone · May 9, 2013 · Viewed 28.9k times · Source

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.

Answer

zavidovych picture zavidovych · Oct 9, 2013

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