How to colorize SeekBar's thumb on Android? -
i use method 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); sb.setthumb(thumb); }
and code works on android 5.0 (lollipop) , newer. on android 4.2.2 or 4.3.1 method doesn't work, color of thumb doesn't change.
what should change color of thumb on older android versions?
create new style in style.xml
<style name="seekbarcolor" parent="widget.appcompat.seekbar"> <item name="coloraccent">@color/your_color</item> </style>
finally in layout
<seekbar android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/seekbarcolor" />
Comments
Post a Comment