12

ここに画像の説明を入力

Material Design GuidelinesでDiscrete Slider - Clickというラベルの付いたシークバー/スライダーのスタイルを設定しようとしています (小さな目盛りインジケーターがあります) 。目盛りを表示させる魔法の呪文がわかりません。これを行う方法を知っている人はいますか?

5 つの位置 (0-4) のシークバーがあります。

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

2 に答える 2

20

style 属性で目盛りを追加します。

<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 ドローアブルを設定して手動で追加します。

<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>
于 2016-09-14T10:13:33.683 に答える