apptik / MultiSlider

Multi functional slider/seekbar( / rangebar / scrubber) for Android
Apache License 2.0
320 stars 80 forks source link

How to set custom drawable for thumb? #86

Open drunkendaddy opened 6 years ago

drunkendaddy commented 6 years ago

I tried:

slider.getThumb(0).setThumb(ContextCompat.getDrawable(getContext(),
                R.drawable.slider_thumb_bg));
slider.getThumb(1).setThumb(ContextCompat.getDrawable(getContext(),
                R.drawable.slider_thumb_bg));

but not working. thumb is not showing.

bmx666 commented 6 years ago

Hi @drunkendaddy, drawable for thumbs is more complicated than a just image

See here for API19 and lower: https://github.com/apptik/MultiSlider/blob/master/lib/src/main/res/drawable/multislider_thumb_material.xml See here for API21 and higher: https://github.com/apptik/MultiSlider/blob/master/lib/src/main/res/drawable-v21/multislider_thumb_material_anim.xml

And docs from Android guide: https://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

Kelvao commented 5 years ago

just use android:thumb="@drawable/your_drawable" in xml

Syjgin commented 5 years ago

Is it possible to use, for example, gradient image as a source for thumb? I was trying to set `<?xml version="1.0" encoding="utf-8"?>

` But, when I tried to set for v21 as follows: `