title: android lollipop animation glitch
body: <p>I have a strange behaviour with the default layout animation in devices running Android 5 (Lollipop). I am using an activity with multiple Fragments which are replaced at runtime using the default fragment manager. When replacing the old fragment, i want to use an animation for a smooth ui flow. On pre-lollipop devices the animation works like expected, but on devices running the latest os, the animation between fragment glitches:</p>
  
  <p><img src="https://i.stack.imgur.com/qGTHO.png" alt="Glitch screen shot"></p>
  
  <p>I tried using the default animation xml tag </p>
  
  <pre><code>android:animateLayoutChanges="true"
  </code></pre>
  
  <p>Because it does not work, i changed it using this code with no effect</p>
  
  <pre><code>mTransaction = mManager.beginTransaction();
          mTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
          mTransaction.remove(mFragment);
          mTransaction.add(R.id.container, mFragment, "fragment");
          mTransaction.commit();
  </code></pre>
  
  <p>I have tested the code on different devices and in the android emulator. The strange thing is, that it works like expected on devices running pre-lollipop <strong>and in</strong> the android emulator running the latest OS (5.0.1). 
  But it does not work on devices like Nexus 4 and Nexus 5 running Android 5.0</p>
  
  <p>Any suggestions? Any Help?</p>
  
  <p>Thanks in Advance</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>It seems to be a bug depending on the used device. I have tested the code on different devices (Samsung Galaxy S4, HTC (One mini2, One M8, Desire S), Nexus 4&amp;5), and it only appears on google nexus devices. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>One Workaround to fix the animation issue is to disable the hardware acceleration via the</p>
  
  <p><code>&lt;application android:hardwareAccelerated="false"&gt;</code> </p>
  
  <p>tag in the app Manifest. But using this makes the app very slow. </p>
  
  <p><strong>Solution</strong></p>
  
  <p>The solution to fix this issue is to set a background image/color/drawable to the activity. <a href="https://stackoverflow.com/questions/27963767/graphical-bug-while-changing-fragment-with-api-21?lq=1">see</a></p>