When navigating through fragments all the animations are working properly except for popenteranim, which does not work at all, and there's no obvious reason why. For example, LoginFragment to Register1AccountFragment (all on the same activity):
Nav graph:
<action
android:id="@+id/action_loginFragment_to_register1AccountFragment"
app:destination="@id/nav_register"
app:enterAnim="@anim/slide_in_from_right"
app:exitAnim="@anim/slide_out_to_left"
app:popEnterAnim="@anim/slide_in_from_left"
app:popExitAnim="@anim/slide_out_to_right" />
Note the destination is a new nav graph, where the startDestination is register1AccountFragment. I did this simply to split the register fragments from the rest of the navigation, and there is only one activity in the app.
LoginFragment
registerButton.setOnClickListener(v -> {
view.clearFocus();
NavDirections action = LoginFragmentDirections.actionLoginFragmentToRegister1AccountFragment();
Navigation.findNavController(v).navigate(action);
});
anim/slide_in_from_left
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXDelta="-100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300" />
So all the other animations work, including popExitAnim, which is just the opposite of slide_in_from_left, i.e.
anim/slide_out_to_right
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:fromXDelta="0%" android:toXDelta="100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300" />
This is the same on all fragments, regardless of their popEnterAnim. I have tried multiple different animations too, like popEnterAnim = fade from 0 alpha to 1 alpha.
I have also tried navigating using the action's ID instead of NavDirections, which still does not show the animation;
LoginFragment
registerButton.setOnClickListener(v -> {
view.clearFocus();
Navigation.findNavController(v).navigate(R.id.action_loginFragment_to_register1AccountFragment);
});