Android KitKat 中的 WebView 渲染问题 [英] WebView Rendering Issue in Android KitKat

查看:37
本文介绍了Android KitKat 中的 WebView 渲染问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发具有 WebView 的应用程序,其中从资产加载静态页面(也使用 JavaScript).此 WebView 在 KitKat 中不起作用,它保持空白.我知道在 kitkat 的 WebView 中发生的渲染引擎的变化(webkit 到chromium)并尝试了迁移步骤,这在Android 开发人员页面中给出.但这没有帮助.

I've been working on an application which have a WebView in which a static page get loaded from the assets (Also using JavaScript). This WebView is not working in KitKat, it remains blank. I am aware of the change in rendering engine (webkit to chromium) which happened in WebView in kitkat and tried the steps for migrating, which is given in Android Developers page. But it didn't help.

在 logcat 中,我收到从 Chromium 源抛出的错误.

In logcat I am getting an error which is thrown from the Chromium source.

W/AwContents:nativeOnDraw 失败;清除为背景颜色.

请提出解决方法.

推荐答案

就我而言,在 Android 4.4 中,无论我设置什么,我都会得到黑色背景,并且我的 LogCat 中出现此错误消息:nativeOnDraw failed;清除为背景颜色.

In my case, in Android 4.4, I was getting a black background no matter I set what and this error message in my LogCat: nativeOnDraw failed; clearing to background color.

通过谷歌搜索,似乎是因为 Chromium WebView 不支持硬件加速画布渲染.我将此行添加到 WebView 以关闭硬件加速画布,现在它可以工作了.

From Googling, it seems to be because hardware accelerated canvas rendering is not supported in Chromium WebView. I added this line to the WebView to turn off hardware accelerated canvas and now it works.

mWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

这篇关于Android KitKat 中的 WebView 渲染问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆