android webview设置和遇到的坑

枕上从妨一夜睡,灯前读尽十年诗。这篇文章主要讲述android webview设置和遇到的坑相关的知识,希望能为你提供帮助。

WebSettings webSettings = webView.getSettings(); webSettings.setCacheMode(webSettings.LOAD_NO_CACHE); //设置不缓存 webSettings.setjavascriptEnabled(true); //支持JS if (Build.VERSION.SDK_INT > = Build.VERSION_CODES.LOLLIPOP) { webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } webView.setInitialScale(50); //设置显示的缩放比例
//String URL = "http://192.168.3.23:8082/#/bigScreen?mac=123456";//URL不能带mac关键字,切记! String URL = "http://192.168.3.23:8082/#/bigScreen?id=123456"; webView.loadUrl(URL);
//加载页面需要设置谷歌浏览器内核 webView.setWebChromeClient(new WebChromeClient() { @Override public void onReceivedTitle(WebView view, String title) { super.onReceivedTitle(view, title); } @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress == 100) { } } });

【android webview设置和遇到的坑】 

    推荐阅读