今天实现webview加载微博网页的功能,开始就是采用了webview.loadurl()方法,直接出现空白页面。当时特别蒙,平时都是直接可以实现效果的,今天居然一直都是空白。后来,在网上查了很多资料。
Android WebView 加载弹出浏览器选择 和 空白页面解决
http://bbs.vpigirl.com/forum.php?mod=viewthread&tid=503&fromuid=2
(出处: 心惊变 回忆的路上,时间变得好慢!)
进行如下设置吧,大多数情况都能解决。
displayWebview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
displayWebview.getSettings().setJavaScriptEnabled(true);
displayWebview.getSettings().setSupportZoom(true);
displayWebview.getSettings().setBuiltInZoomControls(true);
displayWebview.getSettings().setUseWideViewPort(true);
displayWebview.getSettings().setLoadWithOverviewMode(true);
displayWebview.getSettings().setAppCacheEnabled(true);
displayWebview.getSettings().setDomStorageEnabled(true);
缓存不开启的时候,可能会有一些使用了这些存储的网页无法打开。
AppCache和DomStorage介绍见:
http://blog.csdn.net/a345017062/article/details/8703221
本文资料由 微信妈妈(ontaobao.cn公众号买卖平台) 转载于 http://blog.csdn.net/zhanlanmg/article/details/44699627