具有自定义设计的 RangeSlider - Android

问题描述

我想自定义 RangeSlider 的 UI。我已经有了 SeekBar 的设计,现在我想将其转换为 RangeSlider。对于这么小的任务,我不认为使用库是合理的。

我想要达到的结果。查看 SeekBar 的图片

enter image description here

Seekbar Xml XML

    <SeekBar
        android:id="@+id/seek_bar_frost_hard_temperature"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:progressDrawable="@drawable/custom_seekbar_frost_hard"
        android:layout_marginTop="@dimen/margin_padding_size_small"
        android:layout_marginBottom="@dimen/margin_padding_size_small"
        android:max="11"
        android:splitTrack="false"
        android:maxHeight="@dimen/seek_bar_height"
        android:paddingStart="@dimen/margin_padding_size_xsmall"
        android:paddingEnd="@dimen/margin_padding_size_xsmall"
        android:progress="0"
        android:thumb="@drawable/seekbar_frost_hard_thumb"/>

custom_seekbar_frost_hard.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background"
        android:gravity="center_vertical|fill_horizontal">
        <shape android:shape="rectangle"
            android:tint="@color/frost_hard_seekbar_background_color">
            <size android:height="@dimen/frost_seekbar_height" />
            <solid android:color="@color/frost_hard_seekbar_background_color" />
        </shape>
    </item>
    <item android:id="@android:id/progress"
        android:gravity="center_vertical|fill_horizontal">
        <scale android:scaleWidth="100%">
            <selector>
                <item android:state_enabled="false"
                    android:drawable="@android:color/transparent" />
                <item>
                    <shape android:shape="rectangle"
                        android:tint="@color/frost_hard_seekbar_progress_color">
                        <size android:height="30dp" />
                        <solid android:color="@color/frost_hard_seekbar_progress_color" />
                    </shape>
                </item>
            </selector>
        </scale>
    </item>
</layer-list>

seekbar_frost_hard_thumb.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Background -->
    <item>
        <shape>
            <solid android:color="@color/black"/>
            <size
                android:width="4dp"
                android:height="@dimen/seekbar_thumb_frost_hard_height" />
        </shape>
    </item>
</layer-list>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...