2016-02-12 57 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