4

在此处输入图像描述

大家好,

我正在寻找像这张图片一样的搜索栏。我成功设置了背景,但问题是搜索栏下方的拇指和分段文本。有谁知道解决方法谢谢

4

3 回答 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()

这个项目几乎已经完成,但仍然是一个坚实的起点。你可能需要多锻炼一下drawables

于 2014-03-26T00:45:40.313 回答
1

我认为您可以通过对图像进行一些正确的调整来“伪造”它。唯一的问题是它的长度应该是固定的,或者最后你应该通过编码来完成文本。无论如何,android:thumb="@drawable/seek_handler"您可以更改搜索栏的处理程序样式。(请参阅此Android SeekBar thumb Customization

于 2013-05-20T10:25:30.920 回答
1

你可以检查一下。这可能会给你一些想法: 自定义搜索栏

它的源代码在这里: Source code

于 2013-05-20T10:48:03.527 回答