Nearest step seekbar discret

67 views Asked by At

As you can see in this image I have a seekbar with 3 stes.

If I tap (for example) on the black dot, the seekbar will select the second step but the nearest step is the third one.

So, how can I have a seekbar that select the nearest step?

1

There are 1 answers

0
Nikolas On BEST ANSWER

I solved. I converted my 3-step seekbar in a 100-step seekbar. I implemented onStopTrackingTouch (see how here: javatpoint.com/android-seekbar-example). I consider 0 as the first state, 50 as second and 100 as tird. If seekbar.getProgress() is <= 33 the progress will be set to 0, else if it is between 33 and 66 progress will be set to 50 and if it is >= 66 progress will be 100