具有自定义拇指和分段文本的SeekBar

4

enter image description here

大家好,

我正在寻找一个像这个图片中的seekbar。我已经成功设置了背景,但是问题在于thumb和segments下方的文本。有人知道解决方法吗?

谢谢!

3个回答

2

使用这个库,以下是我成功运行的最小示例代码:

<com.infteh.comboseekbar.ComboSeekBar
        xmlns:custom="http://schemas.android.com/apk/res-auto"
        android:id="@+id/seekbar" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        custom:color="#000"
        custom:textSize="12sp"
        custom:multiline="false"
        />

然后在活动中

private ComboSeekBar mSeekBar;
List<String> seekBarStep = Arrays.asList("All","1","5","10","20");
mDistanceSeekBar.setAdapter(seekBarStep);

这将创建一个使用默认可绘制对象的黑色分段拖动条。如果您需要添加一些自定义内容,请查看 ComboSeekBar.onDraw()CustomDrawable.draw()CustomThumbDrawable.draw()

此项目虽然还没有完成,但是作为一个坚实的起点。您可能需要再进一步调整可绘制对象。


1
我认为你可以通过对图像进行一些正确的调整来“假装”它。唯一的问题是它应该是固定长度的,或者至少你应该通过编码来处理文本。 无论如何,使用android:thumb="@drawable/seek_handler",你可以改变SeekBar的处理程序样式。(请参见Android SeekBar thumb Customization)

1

请始终使用GitHub或类似的网站,以便我们无需下载源代码即可查看您的代码。 - LostPuppy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接