请求有关在 Android 中创建自定义 SeekBar 的指导。 (如图所示)

Requesting guidance in creating custom SeekBar in Android. (like shown in the image)

我的任务是创建一个如下所示的 SeekBar:

我的问题是:如何这样分割搜索栏?我以前做过自定义搜索栏,但我不知道如何分割搜索栏,线条超出了搜索栏的高度。

我偶然发现了一个库,ComboSeekBar,但它并没有多大帮助。

提前感谢任何愿意提供帮助的人!

干杯!

我已经看到了两种方法

  1. 使用后台Drawable

    使用 setBackgroundDrawable().

  2. 创建并选择您的搜索栏可绘制对象
  3. 使用 third-party 库:

RangeSliderView: (min. SDK API 14):

https://github.com/channguyen/range-slider-view

RangeSeekbar:

https://github.com/dolphinwang/RangeSeekbar

RangeBar:

https://github.com/edmodo/range-bar

还要检查这个未完成的项目:https://github.com/feelinglucky/RadioSeekBar

希望对您有所帮助

对于像我一样需要创建类似 Seekbar 的任何人:

这个库正是我所需要的,除了它有 2 个拇指,而且无法消除其中一个。

https://github.com/edmodo/range-bar

我为此设计了一些"hack":当您初始化Range-Bar时,您可以通过此方法设置拇指索引,如wiki:[=15中所述=]

RangeBar rangebar = (RangeBar) findViewById(R.id.rangebar);
rangebar.setThumbIndices(5,5); //indices example

当缩略图索引发生变化时,在以下方法中将搜索栏缩略图设置到相同位置:

rangebar.setOnRangeBarChangeListener(new RangeBar.OnRangeBarChangeListener() {
@Override
public void onIndexChangeListener(RangeBar rangeBar, int leftThumbIndex, int rightThumbIndex) { 
    //Code using the leftThumbIndex and rightThumbIndex to update the index values.
    rangeBar.setThumbIndices(leftThumbIndex, leftThumbIndex);
    }
});

希望对大家有用。

感谢大家的帮助!

干杯!