Skip to content

BaseApi

谷进杰 edited this page Jun 18, 2019 · 3 revisions

BaseApi(基本API)

setSeekBarMode 选择单向或范围模式

You should set SeekBarMode firstly. 你应该首先设置模式类型,选择单向还是范围

  • SingleMode 单向 : app:rsb_mode="single" or rangeSeekBar.setSeekBarMode(RangeSeekBar.SEEKBAR_MODE_SINGLE)
  • RangeMode 范围 : app:rsb_mode="range" or rangeSeekBar.setSeekBarMode(RangeSeekBar.SEEKBAR_MODE_RANGE)

setProgress(float leftValue, float rightValue = leftValue) 设置当前进度

set current RangeSeekBar progress 设置当前进度

  • SingleMode 单向 : rangeSeekBar.setProgress(10f)
  • RangeMode 范围 : rangeSeekBar.setProgress(10f, 30f)

getProgress 获取当前进度

get current RangeSeekBar progress 设置当前进度

  • SingleMode 单向: rangeSeekBar.leftSeekBar.getProgress()
  • RangeMode 范围: rangeSeekBar.leftSeekBar.getProgress() and rangeSeekBar.rightSeekBar.getProgress()

setRange(float min, float max, float minInterval = 0) 设置范围

Set the maximum and minimum values. 设置最大值和最小值

minInterval is the minimum value between the two thumbs of RangeSeekBar. (minInterval是RangeSeekBar两个按钮的最小间距值)

//java
rangeSeekBar.setRange(0f, 100f);
rangeSeekBar.setRange(0f, 100f, 30f);

//xml
app:rsb_min="0"
app:rsb_max="100"
app:rsb_min_interval="30"


setGravity(设置内部对齐方式)

Gravity.TOP | Gravity.CENTER | Gravity.BOTTOM

//java
rangeSeekBar.setGravity = RangeSeekBar.Gravity.CENTER;

//xml
app:rsb_gravity="center"


setTypeface(Typeface typeFace)(设置字体)

set custom fonts

//java
rangeSeekBar.setTypeface()

setOnRangeChangedListener(设置监听器)

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
            }
        });