How to change colour of the thumb in seekbar?

前端 未结 3 2128
北荒
北荒 2020-12-15 18:43

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 i

3条回答
  •  甜味超标
    2020-12-15 19:17

    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).

提交回复
热议问题