2

I want to implement a transition between the fragments (exit and enter). First of all I tried the following:

f.setEnterTransition(new Slide(Gravity.RIGHT));
f.setExitTransition(new Slide(Gravity.LEFT));

This is working perfectly on API > 21 but the app crashes on API < 21. Then I tried the answer in this post.

But the problem is that when the fragment is exiting it does not animate. The first fragment is directly gone and the second fragment animates into the screen.

The approach I need is the same as the first solution above. On enter animate the fragment from right to left. On exit push the first fragment to the left and animate the second.

Motassem Jalal
  • 1,254
  • 1
  • 22
  • 46

2 Answers2

0

Have a look at GravityCompat.

Slide(GravityCompat.END)
Entreco
  • 12,738
  • 8
  • 75
  • 95
0

I struggled with the same weird behaviour of exit animation missing. The reason in my case was using wrap_content instead of match_parent for height of the FrameLayout fragment container.

Dharman
  • 30,962
  • 25
  • 85
  • 135
welniak
  • 1
  • 1