Skip to content

IndicatorApi

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

Indicator Style 提示框样式

The indicator is belong to RangeSeekBar.leftSeekBar and RangeSeekBar.rightSeekBar. You can set a different style for each SeekBar.

指示器是属于RangeSeekBar.leftSeekBarRangeSeekBar.rightSeekBar的,所以你可以为它们设置不同的样式。

Show Mode 设置指示器显示模式【重要】

If you want to use the indicator, you need to set the app:rsb_indicator_show_mode first.

Options: showWhenTouch|alwaysHide| alwaysShowAfterTouch| alwaysShow


Height and Width 设置指示器宽高

The indicator‘s height and width also supports wrap_content.

//xml
app:rsb_indicator_width="40dp"
app:rsb_indicator_height="40dp"

Format Text 格式化文字

  • setIndicatorTextDecimalFormat(String format) Format decimal places. 格式化小数位数
  • setIndicatorTextStringFormat(String format) Format string text. 格式化字符串

Examples 示例

Example-1:

rangeSeekBar.setIndicatorTextDecimalFormat("0");

original text: "7.69" formated: "7"

Example-2:

rangeSeekBar.getLeftSeekBar().setIndicatorTextDecimalFormat("0.0");

rangeSeekBar.getLeftSeekBar().setIndicatorTextStringFormat("%s%%");

original text: "7.69" formated: "7.6%"


Margin 设置指示器间距

The indicator‘s margin is between the thumb and the indicator.

//xml
app:rsb_indicator_margin="10dp"

Padding 设置指示器间距

The indicator‘s padding is between the text and the indicator.

//xml
app:rsb_indicator_padding_left="10dp"
app:rsb_indicator_padding_right="10dp"
app:rsb_indicator_padding_top="10dp"
app:rsb_indicator_padding_bottom="10dp"


Indicator Drawable 设置指示器背景

In order to ensure the adaptation effect, it is recommended to use the 9patch file. 为了保证适配效果,建议使用9patch

//java
rangeSeekBar.leftSeekBar.setIndicatorDrawableId()

//xml
app:rsb_indicator_drawable="@drawable/xxx"


Background Color 设置指示器背景颜色

//java
rangeSeekBar.leftSeekBar.setIndicatorBackgroundColor()

//xml
app:rsb_indicator_background_color="@color/xxx"


Indicator Radius 设置指示器圆角

//java
rangeSeekBar.leftSeekBar.setIndicatorRadius()

//xml
app:rsb_indicator_radius="10dp"


Indicator Text Size 设置指示器文字大小

//java
rangeSeekBar.leftSeekBar.setIndicatorTextSize(sp2px(10))

//xml
app:rsb_indicator_text_size="10sp"


Indicator Text Color 设置指示器文字颜色

//java
rangeSeekBar.leftSeekBar.setIndicatorTextColor()

//xml
app:rsb_indicator_text_color="@color/xxx"


Indicator Arrow Size 设置指示器底部箭头尺寸

if you set the indicator background by drawable, this attr will not work. 如果你使用了drawable作为指示器背景,那么此属性则不会生效

//java
rangeSeekBar.leftSeekBar.setIndicatorArrowSize()

//xml
app:rsb_indicator_arrow_size="5dp"