6

In the Android Jetpack navigation component at for instance at here. I was wondering if it were possible to use default system animations (for instance the animation when starting a new activity) when screens change. This would be in the context of the enterAnim and the exitAnim parameters.

1 Answer 1

6

When you're using the editor you can define the animation for the enter and exit transitions:

enter image description here

And if you don't have any animations defined in the anim xml folder there are some default animations available. If none of those is good enough for you, you can simply create a transition that mimics the default ones and set it there.

To get the default animations you need to have the dependence:

implementation "android.arch.navigation:navigation-ui-ktx:1.0.0-alpha01"
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for the answer! I was able to add the custom animations and I can see them in the drop down. However, I don't see the default animations (like nav_default_enter_anim)... I assume I setup my project incorrectly and will keep looking.
Did you add both the navigation-fragment and navigation-ui dependencies?
You'll need the navigation-ui dependence to get the default anim: implementation "android.arch.navigation:navigation-ui-ktx:1.0.0-alpha01"
Is there any way to set the transitions by default to every transition?
For Android Jetpack dependency should be androidx.navigation:navigation-ui-ktx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.