Android Lollipop Activity Screen corrupted

This question already has an answer here:

  • Android SystemUI glitches in Lollipop

    6 answers

  • Open Android app from URL using intent-filter not working
  • OutOfMemoryError while decoding and encoding Base64 String into Bitmap
  • How to Launch android apps within my application in Android?
  • Can't import org.apache.http.HttpResponse in Android Studio
  • Android memory leak in Apache Harmony's JarURLConnectionImpl?
  • Is it really impossible to protect Android apps from reverse engineering?
  • Related posts:

    How to set alarm when mobile has been idle using android?
    Apache HttpClient Digest authentication
    Dynamically change the number of columns of a GridLayoutManager
    Can ViewPager have multiple views in per page?
    OnItemClickListener on a ListView inside a Fragment not working
    Reading Activity names from apk file in Android
  • HorizontalScrollView in TabHost adding extra space on the end
  • HTTP get with headers using RestTemplate
  • What are the most important POSIX functions not available in Android?
  • How to know if an activity is called using startActivityForResult or simply called by using startActivity?
  • Floating Action Button Not Going up when Snack bar is Showing in android
  • How to put views on top of an ImageView, in relation to the ImageView's content size?
  • 3 Solutions collect form web for “Android Lollipop Activity Screen corrupted”

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

    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.

    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.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.