Android Fragment transition exit animation played above enter animation
android, android-animation, android-fragments
Solution
I think you could try the following approach as a work around.
fragmentTr.setCustomAnimations(enter, exit);
fragmentTr.hide(currentFragment);
fragmentTr.add(containerId, newFragment, "aTag");
fragmentTr.show(newFragment);
fragmentTr.commit();
Do not use replace(). I tried the above approach, and it worked. Hope this helps.
Problem
I'm implementing Fragment transition animations. My `exit` animation is ``` <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:ordering="together"> <objectAnimator android:propertyName="scaleX" android:valueType="floatType" android:valueFrom="1.0" android:valueTo="0.95" android:duration="300"/> <objectAnimator android:propertyName="scaleY" android:valueType="floatType" android:valueFrom="1.0" android:valueTo="0.95" android:duration="300"/> <objectAnimator android:propertyName="x" android:valueType="floatType" android:valueFrom="0" android:valueTo="10dp" android:duration="300"/> </set> ``` `enter` animation is: ``` <?xml version="1.0" encoding="utf-8"?> <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" android:propertyName="x" android:valueType="floatType" android:valueFrom="1280" android:valueTo="0" android:duration="400"/> ``` Transaction is created like this: ``` fragmentManager.beginTransaction() .setCustomAnimations(enter, exit, popEnter, popExit) .replace(CONTENT_CONTAINER_ID, newFragment) .addToBackStack(null) .commit(); ``` At normal animation speed the unwanted effect is almost invisible due to short animation duration, but, when you slow them down you can clearly see, that `z-order` is wrong. Entering fragment animation is below exit fragment animation. Is there a workaround to remedy that?