Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android lollipop animation glitch

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

like image 646
user3749883 Avatar asked Jan 12 '15 08:01

user3749883


1 Answers

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

like image 151
Thomas Vos Avatar answered Sep 21 '22 15:09

Thomas Vos