Customizing the android seekbar thumb

2.3k views Asked by At

I want to 1) change the color of the thumb to a color int I have in my code. and 2) make sure there is no whitespace between the progress and the thumb

Drawable thumb = getResources().getDrawable(R.drawable.thumb, getContext().getTheme());
// seekbarColorStr can be #0011FF, etc
thumb.setColorFilter(Color.parseColor(seekbarColorStr), PorterDuff.Mode.MULTIPLY);
seekBar.setThumb(thumb);

My thumb.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="oval">

<size
    android:height="20dp"
    android:width="20dp" />

</shape>

I got the idea for changing the color in How to change colour of the thumb in seekbar?

The thumb renders black, and since it is circular while the progress is rectangular, there is whitespace between the two.

1

There are 1 answers

0
MarcusH On

the proper PorterDuff mode is SRC_IN, not Multiply in order to render the color.