Custom ProgressBar With Multi Color

大兔子大兔子 提交于 2019-11-30 16:06:11

问题


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:


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();
    }
}


来源:https://stackoverflow.com/questions/7175018/custom-progressbar-with-multi-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!