2016-02-12 83 views
9

enter image description here如何显示离散滑块的刻度线?

我试图像样式标记离散滑块上的一个搜索条/滑块 - 点击(具有小刻度线指标)在Material Design Guidelines。我无法弄清楚咒语出现的魔法咒语,有谁知道如何做到这一点?

我有5个位置(0-4)

<SeekBar 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:max="4" /> 
+0

这个问题与提示无关 - 它是关于刻度和材料设计的。 –

回答

12

添加刻度标记的风格属性搜索条:通过设置对勾标记绘制手工

<SeekBar 
    android:id="@+id/seekBar" 
    style="@style/Widget.AppCompat.SeekBar.Discrete" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:max="10" 
    /> 

或将其添加:

<SeekBar 
    android:id="@+id/seekBar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:max="10" 
    android:tickMark="@drawable/tickmark" 
    /> 

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> 
+4

Ahh看起来像是最近在24.x.x支持库中添加的(似乎在23.4.0中不可用) –

+0

@NameSpace我没有在seekbar上获取股票指标,你能帮我吗? – Pankaj