ScrollView嵌套WebView报Unable to create layer for WebView

来源:互联网 发布:云服务器软件 编辑:程序博客网 时间:2024/06/07 17:06
java.lang.IllegalStateException: Unable to create layer for WebView     at android.os.MessageQueue.nativePollOnce(Native Method)     at android.os.MessageQueue.next(MessageQueue.java:323)     at android.os.Looper.loop(Looper.java:138)     at android.app.ActivityThread.main(ActivityThread.java:5524)     at java.lang.reflect.Method.invoke(Native Method)     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:740)     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:630)

这个错误是由于webview在scrollview里设置成了wrap_content,导致webview不确定大小,而且webview启动了硬件加速,由于硬件加速是有个最小的缓存区域的,最终导致超过了缓存范围。
解决方法:
webView.setLayerType(View.LAYER_TYPE_NONE, null);
关闭硬件加速即可,也不能使用软件加速

原创粉丝点击