Hikmat Khan
Hikmat Khan

Reputation: 6434

Custom ProgressBar With Multi Color

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

Upvotes: 3

Views: 4940

Answers (1)

Ron
Ron

Reputation: 24233

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

Upvotes: 2

Related Questions