Skip to content
谷进杰 edited this page Jul 19, 2018 · 7 revisions

1、How to add a Listener to get current seekBar value

  rangeSeekBar.setOnRangeChangedListener(new OnRangeChangedListener() {
            @Override
            public void onRangeChanged(RangeSeekBar view, float leftValue, float rightValue, boolean isFromUser) {
           //leftValue is left seekbar value, rightValue is right seekbar value
            }

            @Override
            public void onStartTrackingTouch(RangeSeekBar view,  boolean isLeft) {
                //start tracking touch
            }

            @Override
            public void onStopTrackingTouch(RangeSeekBar view,  boolean isLeft) {
                //stop tracking touch
            }
        });

2、How to use java code to update some attributes when you want

RangeSeekBar support setter and getter for all attributes, so just do what you want to do in the Listener! If you want to change one of the seekbar's attributes, you can use getLeftSeekBar() or getRightSeekBar() to do it. Just enjoy it !

3、How to set Value

If the singlemode RangeSeekBar, you can use RangeSeekBar.setValue(float value).

If the rangemode RangeSeekBar, you can use RangeSeekBar.setValue(float leftValue, float rightValue)

4、How to set Range

you can use RangeSeekBar.setRange(float min, float max) to limit range.

5、why setXXX method not work?

It is very resource consuming to set up attributes to redraw each time, so you need to call rangeSeekBar.invalidate() to make it work!

6、how to set TypeFace

If you want to set the scale text Typeface,please use rangeSeekBar.setTypeface(typeFace)

If you want to set the indicator text Typeface,please use rangeSeekBar.getLeftSeekBar().setTypeface(typeFace) and rangeSeekBar.getRightSeekBar().setTypeface(typeFace)

7、how to increase hit area of thumb ?

You can use the app:rsb_thumb_scale_ratio="1.2f"to make the thumb easy to drag.

8、how to format indicator text?

You can use the leftSeekBar.setIndicatorTextStringFormat(); or leftSeekBar.setIndicatorTextDecimalFormat(); to format the indicator text.

// Indicator default text: 2.341234532

seekbar2.setIndicatorTextDecimalFormat("0.00");
// Indicator text: 2.34

seekbar4.setIndicatorTextDecimalFormat("0");
// Indicator text: 2

seekbar5.setIndicatorTextStringFormat("it is %s");
// Indicator text: it is 2.341234532

You can know more from the Issues and Demo