Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Seekbar color [closed]

Tags:

android

xml

I want to change SeekBar color, precisely I want to change color of dot that is dragged to change the progress value. I know I can do it by changing "colorAccent" value but that's not what I'm up to.

like image 387
Piotr Konopacki Avatar asked Aug 21 '17 17:08

Piotr Konopacki


1 Answers

The dot you're refering to is called the SeekBar Thumb. To change the color of the Seekbar thumb, create a new style in style.xml

Change Via XML

<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumbTint="your_color"  //gives your color
android:thumb="@drawable/yourseekthumb"  //gives your drawable
android:theme="@style/SeekBarColor" />

You can either give your color using thumbTint or your drawable using android:thumb.

This method works for API>16.

To change SeekBar thumb color by Java code

SeekBar seekbar = (SeekBar) findViewById(R.id.seekBar);
seekbar.getThumb().setColorFilter(your_color, PorterDuff.Mode.MULTIPLY);

This method works for only android 5 and above.

like image 100
Abhi Avatar answered Nov 05 '22 10:11

Abhi