2

I'm replacing Fragment with :

Fragment fragment = new TheFragment();
fragment.setAllowEnterTransitionOverlap(false);

getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.fade_in, R.anim.fade_out).replace(R.id.LayoutContent, fragment).commit();

But the enter en exit animation are played at the same time.

How can I wait for exit animation to finish before playing the new Fragment enter animation ?

Fluckysan
  • 21
  • 4

3 Answers3

2

I know this is already late but I would like to answer for others having the same issue.

fragment.setAllowEnterTransitionOverlap(false);
fragment.setAllowReturnTransitionOverlap(false);

only works for Content Transition - transition set directly at the fragment.

enteringfragment.setEnterTransition(new YourTransition())
exitingfragment.setExitTransition(new YourTransition())

it does not affect the animation set at the setCustomAnimations()

Archie G. QuiƱones
  • 11,638
  • 18
  • 65
  • 107
1

Maybe a little bit dirty but I solved this problem by just defining the

android:startOffset

of the enter animation with the same value as the

android:duration

of the exit animation. Additionally I used the time from a variable to make sure that it is always the same value in both animations and I only have to change it at one place.

Moema
  • 863
  • 4
  • 10
0

You don't need to do that. Simply use

setAllowEnterTransitionOverlap(false);
setAllowExitTransitionOverlap(false);

on both fragments and it works.