How to change colour of the thumb in seekbar?

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.

  • Google Espresso or Robotium
  • Android: Create ListView in XML?
  • WakeLock finalized while still held
  • unexpected error while parsing input invalid uiautomator hierarchy file
  • SINGLE_TOP | CLEAR_TOP seem to work 95% of the time. Why the 5%?
  • Loading a URL inside a TXT in a Webview
  • How do I explicitly disable chunked streaming mode for HTTP connections in Android?
  • Strange View.getHitRect() behaviour
  • OpenGL extensions available on different Android devices
  • Google Analytics in Android app - dealing with multiple activities
  • Android - margins specified in custom style not taking effect
  • How to write style to error text of EditText in android?
  • 3 Solutions collect form web for “How to change colour of the thumb in seekbar?”

    If you don’t like the default thumb, you will have to create your own Drawable, which you can then set the thumb in code with something like:

    Drawable thumb = getResources().getDrawable( R.drawable.myThumb );
    SeekBar mSeekBar = (SeekBar) findViewById(R.id.mySeekBar);
    mSeekbar.setThumb(thumb);
    

    Or you can set the thumb in XML with:

    <SeekBar 
        ...
        android:thumb="@drawable/seek_thumb" />
    

    The actual Drawable can be an image, shape, or any other kind of Drawable you could possibly desire. If you want the thumb to change appearance when it is pressed, you will want to create a State List Drawable.

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

    No need of additional styling. Android supports it via xml.
    Just add android:thumbTint=”@color/yourColor” in your seekbar.

    For eg.

    <SeekBar
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:max="100"
         android:thumbTint="@color/red"
         android:progress="0" />
    
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.