6

I'm developing an app with over 50 screens. At the moment my actions look like that

    <action
        android:id="@+id/action_next"
        app:destination="@+id/introFragment"
        app:enterAnim="@anim/nav_default_enter_anim"
        app:exitAnim="@anim/nav_default_exit_anim"
        app:popEnterAnim="@anim/nav_default_pop_enter_anim"
        app:popExitAnim="@anim/nav_default_pop_exit_anim" />

Can I define in single place default transitions for all actions in my app and remove over 200 lines of code :)

        app:enterAnim="@anim/nav_default_enter_anim"
        app:exitAnim="@anim/nav_default_exit_anim"
        app:popEnterAnim="@anim/nav_default_pop_enter_anim"
        app:popExitAnim="@anim/nav_default_pop_exit_anim"
jakub
  • 3,576
  • 3
  • 29
  • 55
  • I haven't used that API a lot, so it's just a guess, but I suppose you could do it by [building `NavAction` programmatically](https://developer.android.com/reference/androidx/navigation/NavOptions.Builder) instead of using XML. Maybe it's possible to use a hybrid approach, I don't know. – arekolek Oct 15 '18 at 10:08
  • NavAction is final, so it cannot be extended. – duggulous May 08 '19 at 17:50
  • There is an [open ticket](https://issuetracker.google.com/issues/111759776) at google issue tracker. Hope that will be possible some day. – dhabensky May 25 '19 at 18:06
  • The project I am working on is uses a modular clean architecture, and we deeplink to almost everything, i have a class in my :core module that feature modules use to request navigation, and it knows about the deeplinks. When you navigate with a deeplink you can supply NavOptions. So can have a standard navigateWithDeeplink with default NavOptions, then also allow the caller to supply custom NavOptions if you need to do a different transition – Saik Caskey Feb 06 '20 at 08:44

0 Answers0