Discrete SeekBar

I am trying to create a discrete search string for an android application.

Example

I know that I can set the maximum and minimum values ​​for the SeekBar (the Click example below is my ideal solution), but I want the panel to move up and down the slider at certain intervals - every 10 in my case. Thus, the only options available on the SeekBar will be:

  • 20
  • thirty
  • 40
  • 50
  • 60
  • 70

Is it possible to determine specific values ​​for a standard Android SeekBar or at least change the spacing between elements. If not, is this possible with a custom search bar? I have not found anything on the Internet that addresses this (not for Android at least - disappointment as its recognized component in the Google Material Design Guide).

+5
source share
2 answers

Android SeekBar cannot set intervals, but you can set the maximum value to 10 so that the range is [0, 10], and whenever you want a value from it, multiply the value of SeekBar by 10, so you can "simulate" the intervals at 0, 10, 20, 30, ...

+1
source

Check this link If you want to implement a discrete search bar with the number of spaces without using a third-party library, then use the style property to search.

 <SeekBar android:id="@+id/sb" android:layout_width="match_parent" android:layout_height="wrap_content" android:max="10" android:thumb="@drawable/ic_location" android:theme="@style/Widget.AppCompat.SeekBar.Discrete" /> 

enter image description here

+11
source

Source: https://habr.com/ru/post/1241086/


All Articles