I\'m trying to make a SeekBar move more smoothly than just jumping straight to the position. I\'m doing this as I\'ve got a SeekBar with 3 options for a slider-type implementati
You don't need to build anything by yourself just user android animation it will do the thing for you
The code written in kotlin
mySeekbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
//Todo: code
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
if (seekBar.progress > 70) {
ObjectAnimator.ofInt(seekBar, "progress", 100).setDuration(100).start()
} else if (seekBar.progress < 30) {
ObjectAnimator.ofInt(seekBar, "progress", 0).setDuration(100).start()
} else {
ObjectAnimator.ofInt(seekBar, "progress", 50).setDuration(100).start()
}
}
})