Android Seekbar with Two Thumbs

Android Seekbar with two thumbs

I too was looking for this, to no avail. So I made a new widget, feel free to use it: https://github.com/anothem/android-range-seek-bar

Screenshot of RangeSeekBar

Seekbar where I can change both min max value with 2 thumbs

Just use the RangeSlider in Material Components and the method setValues()

    <com.google.android.material.slider.RangeSlider
android:id="@+id/slider"
android:valueFrom="0"
android:valueTo="10"
../>

with:

RangeSlider slider = findViewById(R.id.slider);
slider.setValues(1.0f,5.0f);

Sample Image

You can also use:

    <com.google.android.material.slider.RangeSlider
android:id="@+id/slider"
android:valueFrom="0"
android:valueTo="10"
app:values="@array/initial_slider_values"
../>

with res/values/arrays.xml:

<resources>
<array name="initial_slider_values">
<item>1.0</item>
<item>5.0</item>
</array>
</resources>

Note: This requires a minimum of version 1.2.0-beta01

How to set range between two thumbs in range seek bar in android?

For stopping the motion of thumbs when the difference is 4. You can use

if(diff==4) {
bar.setEnabled(false);
}

For getting more clear go to our blog and see How to disable thumbs while dragging in RangedSeekBar section.



Related Topics



Leave a reply



Submit