android - RangeSlider 自定义设计 - Android
问题描述
我想自定义RangeSlider
. 我已经有了一个设计SeekBar
,现在我想将其转换为RangeSlider
. 对于这么小的任务,我认为使用库是不合理的。
搜索栏 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>
解决方案
推荐阅读
- reactjs - ReactWrapper 只能包装有效元素(material-ui - 酶)
- python - 具有超过百万个进程的多处理 apply_async 变得更慢
- css - 如何使用 clip-path 属性实现清晰的边框
- javascript - 在 puppeteer 中使用 CSS 选择器单击元素
- python - 脚本返回想要的字符串,但在它后面加上 '\n'
- bash - BASH:关于哈希表/字典和错误替换的问题
- javascript - javascript用默认值初始化对象中的每个值
- javascript - 使用javascript跟踪qualtrics中多项选择题的所有选择
- arrays - Powershell -include $variable 麻烦
- c++ - 包含头文件的函数