15

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:

Glitch screen shot

I tried using the default animation xml tag

android:animateLayoutChanges="true"

Because it does not work, i changed it using this code with no effect

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();

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 and in 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

Any suggestions? Any Help?

Thanks in Advance

EDIT:

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&5), and it only appears on google nexus devices.

EDIT

One Workaround to fix the animation issue is to disable the hardware acceleration via the

<application android:hardwareAccelerated="false">

tag in the app Manifest. But using this makes the app very slow.

Solution

The solution to fix this issue is to set a background image/color/drawable to the activity. see

Community
  • 1
  • 1
user3749883
  • 184
  • 3
  • 12

1 Answers1

2

Set the background color of the root activity (also when not visible to the user!) and the graphical glitch is gone.

Thomas Vos
  • 12,271
  • 5
  • 33
  • 71
  • 1
    This solution is only working for a few devices. Still have this issue on Nexus 5 – user3749883 Apr 10 '15 at 10:27
  • I had the same problem of glitch but playing a youtube video with its Youtube Api Library. The issue was only in Nexus 5 when I changed the orientation. I solved it setting the background color of the root layout everytime there is a orientation change. – Jose M Lechon Mar 17 '16 at 08:57