Custom ProgressBar With Multi Color

后端 未结 1 582
时光说笑
时光说笑 2021-01-03 09:03

My Application requirement is custom progressbar.A Custom Progress Which have Multicolor Indication.For example Progress Smaller than 30 shown with Green Color .Progress Sma

相关标签:
1条回答
  • 2021-01-03 09:42

    Extend the Seekbar class and override its onDraw() method. There you can draw the thumb and progress background however you want.


    Create a drawable progress background statically (easier than drawing in program.) and add to resources. You can set this as progress drawable in xml or in your custom class constructor.

    class MySeekbar extends Seekbar {
    
        // In Constructor load the thumb image into static members.
    
        // override onDraw draw the thumb.
        void onDraw(Canvas canvas) {
             canvas.save();
             canvas.drawBitmap(mThumb, left, top, right, bottom);
             canvas.restore();
        }
    }
    
    0 讨论(0)
提交回复
热议问题