If you do not use the system-titlebar (that is, the activity is set @android:style/theme.notitlebar), you need to write the progress bar yourself, which encapsulates a custom control and a public activity that loads the Web page for ease of use.
One, screenshot
Two, custom controls
/** * WebView * @author Farmer @see * * * * * * * * * * * * * with progress bar * */@Suppr
Esswarnings ("deprecation") public class Progresswebview extends WebView {private ProgressBar ProgressBar;
Public Progresswebview (context, AttributeSet attrs) {Super (context, attrs); ProgressBar = new ProgressBar (context, NULL, Android.)
R.attr.progressbarstylehorizontal);
Progressbar.setlayoutparams (New Layoutparams (layoutparams.fill_parent, 3, 0, 0));
AddView (ProgressBar);
Setwebviewclient (New Webviewclient () {});
Setwebchromeclient (New Webchromeclient ()); The public class Webchromeclient extends Android.webkit.WebChromeClient {@Override public void Onp Rogresschanged (webview view, int newprogress) {if (newprogress = =) {Progressbar.setvisib
Ility (GONE); else {if (progressbar.getvisibility () = =GONE) progressbar.setvisibility (VISIBLE);
Progressbar.setprogress (newprogress);
} super.onprogresschanged (view, newprogress); } @Override protected void onscrollchanged (int l, int t, int oldl, int Oldt) {Layoutparam
S LP = (Layoutparams) progressbar.getlayoutparams ();
lp.x = l;
LP.Y = t;
PROGRESSBAR.SETLAYOUTPARAMS (LP);
Super.onscrollchanged (L, T, OLDL, Oldt); }
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/