简体   繁体   中英

SeekBar : Change Tick color

I am using Discrete seekbar. I want to change the color of inactive tick marks.

在此处输入图像描述

Here's my SeekBar

<SeekBar
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:max="10"
    android:progress="7" />

What have I tried so far?

  • Applied custom style that extends Widget.AppCompat.SeekBar.Discrete and tried applying colorControl*
  • Applied android:tickMark with different states state_focused=false, state_activated=false , but I think it applies to all tick marks.

Question?

How can I set color of the SeekBar 's tick marks for the inactive portion of the track?

Note

I am aware about the MaterialComponent 's Slider . My requirement is to make it possible with SeekBar .

You could set android:tickMark drawable, but I don't think it supports state list for each of the ticksmark. As you mentioned Material Slider has tickColorActive & tickColorInactive attrs. If implementing the behavior with the traditional seek bar is a must, You may need to play with onDraw method of the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM