Search code examples
androidandroid-jetpackandroid-architecture-navigationandroid-jetpack-navigation

Where is @anim/fragment_fade_enter included in?


@anim/fragment_fade_enter was included in androidx.fragment:fragment-ktx:1.2.4 but after I updated it to version 1.3.3 I can't seem to be able to resolve it anymore, all I can find online that it's supposed to be included in Androidx Core https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/animator/fragment_fade_enter.xml but using androidx.core:core-ktx:1.3.2 doesn't help either.

Did it get refactored into another dependency?


Solution

  • The @anim/fragment_ resources were always a private implementation detail of the various FragmentTransaction.TRANSIT_ fields (i.e., TRANSIT_FRAGMENT_FADE) used in the FragmentTransaction.setTransition() API.

    As per the Fragment 1.3.0 release notes:

    • TRANSIT_ animation changes: The fragment default effects, TRANSIT_FRAGMENT_OPEN, TRANSIT_FRAGMENT_CLOSE, and TRANSIT_FRAGMENT_FADE, now use Animator instead of Animation. The resources used to build these animators are now private.

    So if you are using Fragments by themselves, you should use the setTransition() API, rather than manually using any of those private animators.

    If you are using the Navigation Component, the navigation-ui dependency does offer public animators as of the Navigation 2.3.1 release. You'd use those with:

    • @animator/nav_default_enter_anim
    • @animator/nav_default_exit_anim
    • @animator/nav_default_pop_enter_anim
    • @animator/nav_default_pop_exit_anim

    As of this time, those are also fade animations.