6

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?

Corryn
  • 93
  • 7
  • Found a solution? I have the same issue on 2.3.5. Now trying 2.2.2 where I know that it worked.. Let me know! – Andre Thiele Apr 17 '21 at 18:41
  • 1
    I believe the specific issue here was that fragment A was performing too much when shown, causing the pop animation to lag to the point of not even seeming to play. I disabled most of the functionality in the fragment and tried the pop action again and found it to be smooth. I had a similar issue elsewhere in which the first opening of a fragment was choppy and repeat animations were smooth. I stopped using the Android Navigation library around the time of this issue as well, so I can't say for sure that I resolved this while using the library. Hope that helps somewhat. – Corryn Apr 18 '21 at 22:11

0 Answers0