P. Ilyin P. Ilyin - 3 years ago 114
Android Question

How to colorize SeekBar's thumb on Android?

I use this method to change SeekBar's thumb color:

public static void setThumbColor(final SeekBar sb, @ColorInt final int color) {
final Drawable thumb = sb.getThumb();
thumb.setColorFilter(color, PorterDuff.Mode.SRC_IN);

and this code works well on Android 5.0 (Lollipop) and newer. But on Android 4.2.2 or 4.3.1 my method doesn't work, color of thumb doesn't change.

What should I do to change color of thumb on older android versions?

Answer Source

Create a new style in style.XML

<style name="SeekBarColor"
<item name="colorAccent">@color/your_color</item> 

Finally in the layout

   android:theme="@style/SeekBarColor" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download