Android Define step value for RangeSeekBar edit

Define step value increment for custom RangeSeekBar




A customization of the Android RangeSeekBar proposed by Alex Florescu at

It allows to define a step value (increment), when moving the seek bar


1- Add the increment attribute in attrs.xml

<attr name="increment" format="integer|float"/>

2- Define a default value in and create the attribute also

private static final int DEFAULT_INCREMENT = 1;
private int increment;

3- Init the increment value in private void init(Context context, AttributeSet attrs)

if (attrs == null) 
    increment = DEFAULT_INCREMENT;
    increment = a.getInt(R.styleable.RangeSeekBar_increment, DEFAULT_INCREMENT);

4- Define the increment value in protected synchronized void onDraw(@NonNull Canvas canvas)

You’ll have to replace the minText and maxText value. So instead of :

You’ll have :

int x;

x = (int) ((getSelectedMinValue().intValue()+increment)/increment);
x = x*increment;
if (x<absoluteMaxValue.intValue()) 
    minText = ""+x;

x = (int) ((getSelectedMaxValue().intValue()+increment)/increment);
x = x*increment;
maxText = ""+x;

5 - Now you just have to use it. Hope it helps

Feedback about page:

Optional: your email if you want me to get back to you:

Define step value for RangeSeekBar/
Define step value increment for custom RangeSeekBar
Define a step value of 7

Table Of Contents
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
196 Define step value for RangeSeekBar
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close