Android Studio Range Slider With Custom Thumb

300 Views Asked by At

I have a RangeSlider in my android project I want to change my thumbs with one of my drawables. When i tried it with seekbar in my xml code this works ->

android:thumb="@drawable/my_drawable"

but it doesn't work with sliders or range slider. Is there any way to customise thumbs of range sliders?

1

There are 1 best solutions below

0
Sajjad Yousefnia On

Try this programmitically through these methods :

for all values ->

public void setCustomThumbDrawable (Drawable drawable)

public void setCustomThumbDrawable (int drawableResId)

for specific values :

public void setCustomThumbDrawablesForValues (Drawable... drawables)

public void setCustomThumbDrawablesForValues (int... drawableResIds)

for example :

val rangeSlider = findViewById<RangeSlider>(R.id.movie_rating_range_slider)
    rangeSlider.setCustomThumbDrawable(R.drawable.ic_apple)