Android WebView 无法渲染网页,直接显示html代码?

Android WebView 无法渲染网页,直接显示html代码

Android WebView 无法渲染网页,直接显示源代码,但是在iOS上用WebView可以显示,通手机中的浏览器也可以显示。

settings 的设置如下
    webSettings.setJavaScriptEnabled(true);//允许使用js
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webSettings.setSupportZoom(true);
    webSettings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDomStorageEnabled(true);//设置适应Html5 //重点是这个设置
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setBlockNetworkImage(false);//解决图片不显示
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setLoadsImagesAutomatically(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webSettings.setMixedContentMode(
                WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
运行结果及报错内容

img

不知道什么原因,希望哪位高人指点一下,谢谢

代码不完整,是不是在加载完成事件里还有做什么?

可以加载 https://www.baidu.com/不

有可能是里面的js或者css 样式有问题。导致渲染出错了。可以注释掉js和css 来排查下是否是这方面原因导致的