I just used an online style generator which gave me what i needed
http://android-holo-colors.com/
Just choose the widget and color you want and you are ready! ;)
Frage
I have a seekbar and i am trying to change the thumb color. I found two photos that describes what i actually want to do. I have this seekbar (default) :
and i am trying to change it's color thumb like this.. : (I know how to change background progress color but not the thumb color)..
seekBar1calling.getProgressDrawable().setColorFilter(Color.WHITE, Mode.SRC_IN);
Is there any way to achieve this using java code? Thanks in advance!!
Lösung
I just used an online style generator which gave me what i needed
http://android-holo-colors.com/
Just choose the widget and color you want and you are ready! ;)
Andere Tipps
Just use:
mySeekbar.getThumb().setColorFilter(myColor, PorterDuff.Mode.MULTIPLY);
Edit: method getThumb is only available since API 16+ (Jelly Bean).
The other answers are old and didn't work for me, this did.
seekbar.setThumbTintList(ContextCompat.getColorStateList(this, R.color.disabled));
Here is a quick and easy solution which worked for me as expected. Just implement this code after you initialized the seekbar to avoid NPE's.
You have to define the color itself under res/values/colors.xml
int blue = ContextCompat.getColor(context, R.color.seekbar_blue);
filterSeekBar.getThumb().setColorFilter(blue, PorterDuff.Mode.SRC_ATOP);
filterSeekBar.getProgressDrawable().setColorFilter(blue, PorterDuff.Mode.SRC_ATOP);
That's all!
Note: The color of the Progress-Background is not as dark as the Button / Thumb itself. If you want to know more about the PorfuerDuff part check this answer on Stackoverflow: Phasmal & Lee's answer to PorfuerDuff modes