The default progress bar does not contain text progress prompts. to display the progress more intuitively, The progressbar control is customized to display the text progress:
That is to say, it is very powerful to add a text display progress bar (with % 100) to the progressbar,
Refer to here:Http://orgcent.com/android-text-progressbar/
I am not talking nonsense about the Code directly:
/***** @ Author lixiaodaoaaa * http://weibo.com/lixiaodaoaaa * http://t.qq.com/lixiaodaoaaa */public class textprogressbar extends progressbar {private string STR; private paint mpaint; Public textprogressbar (context) {super (context); inittext ();} public textprogressbar (context, attributeset attrs, int defstyle) {super (context, attrs, defstyle); inittext ();} public textprogressbar (context, attributeset attrs) {super (context, attrs); inittext () ;}@ overridepublic void setprogress (INT progress) {settext (Progress); super. setprogress (Progress) ;}@ overrideprotected synchronized void ondraw (canvas) {super. ondraw (canvas); rect = new rect (); this. mpaint. gettextbounds (this. STR, 0, this. str. length (), rect); int x = (getwidth ()/2)-rect. centerx (); // place the actual font in the center; int y = (getheight ()/2)-rect. centery (); // place the displayed font in the center; canvas. drawtext (this. STR, X, Y, this. mpaint);} // initialization, brush private void inittext () {This. mpaint = new paint (); this. mpaint. setantialias (true); // you can specify the value of this parameter. mpaint. setcolor (color. white);} // set the text content private void settext (INT progress) {int I = (INT) (Progress * 1.0f/This. getmax () * 100); this. STR = string. valueof (I) + "% ";}}