How to use shared element transitions in Navigation Controller

前端 未结 9 545
醉话见心
醉话见心 2021-01-31 08:06

I would like to add a shared elements transition using the navigation architecture components, when navigating to an other fragment. But I have no idea how. Also in the document

9条回答
  •  执念已碎
    2021-01-31 08:25

    Since 1.0.0-alpha06 the navigation component supports adding shared element transitions between destinations. Just add FragmentNavigatorExtras to navigate() call. More details: https://developer.android.com/guide/navigation/navigation-animate-transitions#shared-element

    val extras = FragmentNavigatorExtras(
        imageView to "header_image",
        titleView to "header_title")
    view.findNavController().navigate(R.id.confirmationAction,
        null, // Bundle of args
        null, // NavOptions
        extras)
    

提交回复
热议问题