【问题标题】:SeekBar with custom thumb and segmented text带有自定义拇指和分段文本的 SeekBar
【发布时间】:2013-05-20 09:55:14
【问题描述】:

大家好,

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

【问题讨论】:

    标签: android custom-controls seekbar


    【解决方案1】:

    在这里使用this library 是对我有用的最小示例代码:

    <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"
            />
    

    然后在Activity中

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

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

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        你可以检查一下。这可能会给你一些想法: custom seek bar

        它的源代码在这里: Source code

        【讨论】:

        • 始终使用 github 或类似网站,我们可以在这些网站上查看您的代码,而无需下载您的源代码。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-05
        • 1970-01-01
        • 2011-12-05
        相关资源
        最近更新 更多