How to change colour of the thumb in seekbar?

前端 未结 3 2122
北荒
北荒 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:31

    If you don't like the default thumb, you will have to create your own Drawable, which you can then set the thumb in code with something like:

    Drawable thumb = getResources().getDrawable( R.drawable.myThumb );
    SeekBar mSeekBar = (SeekBar) findViewById(R.id.mySeekBar);
    mSeekbar.setThumb(thumb);
    

    Or you can set the thumb in XML with:

    
    

    The actual Drawable can be an image, shape, or any other kind of Drawable you could possibly desire. If you want the thumb to change appearance when it is pressed, you will want to create a State List Drawable.

提交回复
热议问题