I am currently trying to use the Android Navigation component to navigate from one fragment (A) to another (B) by animating fragment B up from the bottom of the screen (over fragment A) and subsequently animating fragment B back down when the back button is pressed. I currently have an action defined for this:
<action
android:id="@+id/action_landingFragment_to_bookingFragment"
app:destination="@id/bookingFragment"
app:enterAnim="@anim/booking_screen_in"
app:exitAnim="@anim/nothing"
app:popEnterAnim="@anim/nothing"
app:popExitAnim="@anim/booking_screen_out"
app:popUpTo="@id/landingFragment" />
However, when I navigate to fragment B from fragment A currently, I get a nice smooth slide up from the bottom of the screen, hit the back button and see fragment B disappear instantly to display fragment A again, with no animation. I currently use no custom code for the back button on fragment B (though I tried navigateUp()
and popBackStack()
in an OnBackPressedCallback
to see if I was missing something regarding these. I also wonder if there is an issue with Z-axis of the fragments (similar to this thread) but my normal enter/exit animations work fine and I have tried a more traditional set of animations (slide left/right) in which the enter and exit animations play but the pop animations once again do not.
Can anyone suggest the correct way to do back navigation such that these pop animations should be visible?