/*** progress bar with text hint*/ Public classTextprogressbarextendsProgressBar {PrivateString text; PrivatePaint Mpaint; PublicTextprogressbar (Context context) {Super(context); Inittext (); } PublicTextprogressbar (context context, AttributeSet attrs,intDefstyle) { Super(context, attrs, Defstyle); Inittext (); } PublicTextprogressbar (Context context, AttributeSet attrs) {Super(context, attrs); Inittext (); } @Override Public voidSetprogress (intprogress) {SetText (progress); Super. Setprogress (progress); } @Overrideprotected synchronized voidOnDraw (canvas canvas) {Super. OnDraw (canvas); Rect rect=NewRect (); This. Mpaint.gettextbounds ( This. text, 0, This. Text.length (), rect); intx = (GetWidth ()/2)-Rect.centerx (); inty = (getheight ()/2)-Rect.centery (); Canvas.drawtext ( This. text, x, Y, This. Mpaint); } //Initialize, brush Private voidInittext () { This. Mpaint =NewPaint (); This. Mpaint.setantialias (true); This. Mpaint.setcolor (Color.White); } //Set text content Private voidSetText (intprogress) { inti = (int) ((Progress * 1.0f/ This. Getmax ()) * 100); This. Text = string.valueof (i) + "%"; } }