如何显示离散滑块的刻度线? [英] How to show tick marks for Discrete Slider?
本文介绍了如何显示离散滑块的刻度线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm trying to style a seekbar/slider like the one labeled Discrete Slider - Click (that has the little tick mark indicators) in the Material Design Guidelines. I can't figure out the magical incantation to have the tickmarks show up, does anyone know how to do this?
我有一个5个位置(0-4)的搜索栏
I have a seekbar with 5 positions (0-4)
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="4" />
推荐答案
添加带有style属性的刻度线:
Add tick marks with the style attribute:
<SeekBar
android:id="@+id/seekBar"
style="@style/Widget.AppCompat.SeekBar.Discrete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
/>
或通过设置tickMark drawable手动添加它们:
Or add them manually by setting the tickMark drawable:
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="10"
android:tickMark="@drawable/tickmark"
/>
tickmark.xml
tickmark.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="4dp"
android:height="4dp"/>
<solid android:color="@android:color/white"/>
</shape>
这篇关于如何显示离散滑块的刻度线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文