Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

android - How to change colour of the thumb in seekbar?

I have the default seekbar in my android app. I noticed that when the thumb on the seekbar is held, it turns yellow. Instead, I want it to turn blue when it is held. How can this be done? I apologize if this is a basic question, I am new to android development. Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use image filters to change color of default State List Drawables (including SeekBar):

  // Change seekbar color to green.
  SeekBar sb = (SeekBar) findViewById(R.id.seekBar1);
  sb.getProgressDrawable().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY);
  sb.getThumb().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY);

The method getThumb is only available since API 16+ (Jelly Bean).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...