Search code examples
androidseekbar

Android - Seekbar tick mark color not able to change


I am using Discrete seekbar. I want to change the color of tick marks. I am trying like following.

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

And also I create style and applied in tickMark.

drw_bg_tickmark.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:tint="@color/colorAccent">
    <corners android:radius="4dp"/>
    <size android:width="10dp"
        android:height="10dp" />
    <solid android:color="@color/colorAccent" />
</shape>

Applied in seekbar

android:tickMark="@drawable/drw_bg_tickmark"

But I am not able to remove the gray ticks in the seek bar. Please help me on this.

enter image description here


Solution

  • If you want to remove the gray ticks/balls you can just remove the style, and apply your drawable to android:tickMark

    <SeekBar
        android:id="@+id/seekBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:max="10"
        android:tickMark="@drawable/drw_bg_tickmark"
        android:thumbTint="@color/colorPrimary"
        android:tickMarkTint="@color/colorAccent"/>