Custom ProgressBar With Multi Color

2019-02-11 00:05发布

My Application requirement is custom progressbar.A Custom Progress Which have Multicolor Indication.For example Progress Smaller than 30 shown with Green Color .Progress Smaller than 60 and Greater than 30 shown with yellow color and finally the Progress From 60 to 100 Shown with Red Color .

i would like to make progress bar like this

http://www.android2freeware.com/Application/34/2011-08/10906.html#.TlTvqmEmsg_

I am new to android development.

Thanks In Advance

1条回答
时光不老,我们不散
2楼-- · 2019-02-11 00:44

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();
    }
}
查看更多
登录 后发表回答