Ramotion / fluid-slider-android

:octocat:💧 A slider widget with a popup bubble displaying the precise value selected. Android library made by @Ramotion
https://www.ramotion.com/agency/app-development/
MIT License
1.42k stars 147 forks source link

FluidSlider disable help wanted. #40

Closed sanjaypatel27 closed 5 years ago

sanjaypatel27 commented 5 years ago

hello I want to disable the FluidSlider in some condition. I want to stop the user to slide the FluidSlider in some case and in another case they can use the FluidSlider to change value. I tried to use disable and clickable but it's not working. can you please help me with this.

golovin47 commented 5 years ago

Hello, @sanjaypatel27. To disable any interaction with slider you need to set your own touch listener to it. You can do it this way:

slider.setOnTouchListener { view, motionEvent ->
            return@setOnTouchListener true
        }

Returning true will disable it. To enable it you need to set touch listener again, but it should return false. You can do it this way:

slider.setOnTouchListener { view, motionEvent ->
            return@setOnTouchListener false
        }
sanjaypatel27 commented 5 years ago

Thank you so much @golovin47.