Android Lollipop Activity Screen corrupted [duplicate]

断了今生、忘了曾经 提交于 2019-12-17 16:29:32

问题


I build my App with Android Lollipop SDK (21). After opening some activities and close they, one activity has this corrupted screen. It looks like a Memory error, but this happens only on Android Lollipop devices. In the Logcat i cant see errors.

Any ideas what this is?


回答1:


webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); solves the problem.




回答2:


It should also happen on 4.4. Try to always assign a background to your fragment or activity. update Somebody did try using a transparent bkg and it didn't work.




回答3:


The solution

webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

is OK, but a bit overkill since this issue only applies to Nexus devices on 5.0 Lollipop. Why punish all phone models?

boolean isLollipop = android.os.Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP;
boolean isNexus = android.os.Build.MODEL.toLowerCase().contains("nexus");

if (isLollipop && isNexus) {
    webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

This code assumes that Google will fix the problem in the next version of the OS.

Edit

As of 5.1 this has been fixed, which this code handles.



来源:https://stackoverflow.com/questions/27224394/android-lollipop-activity-screen-corrupted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!