WebView基本用法
contentWebView.getSettings().setJavaScriptEnabled(true);
contentWebView.getSettings().setSupportZoom(true);
contentWebView.getSettings().setBuiltInZoomControls(true);
contentWebView.getSettings().setDisplayZoomControls(false);
contentWebView.getSettings().setUseWideViewPort(true);
contentWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
contentWebView.setInitialScale(120)
WebViewClient用于帮助WebView处理各种通知和请求事件
@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlConection) {
}
@Override
public void onReceivedError(WebView view, int errorCode,String description, String failingUrl) {
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
}
@Override
public void onPageFinished(WebView view, String url) {
}
WebChromeClient更丰富一些,帮助WebView处理Javascript各类对话框、弹窗等。
onCloseWindow
onCreateWindow()
onJsAlert
onJsPrompt
onJsConfirm
onProgressChanged
onReceivedIcon
onReceivedTitle