如何在导航控制器中使用共享元素过渡 [英] How to use shared element transitions in Navigation Controller

查看:89
本文介绍了如何在导航控制器中使用共享元素过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

导航到另一个片段时,我想使用导航体系结构组件添加共享元素转换.但是我不知道如何.同样在文档中也没有关于它的内容.有人可以帮我吗?

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 documentations there is nothing about it. Can someone help me?

推荐答案

我从这个github示例中获取了参考 https://github.com/serbelga/android_navigation_shared_elements

I took reference from this github sample https://github.com/serbelga/android_navigation_shared_elements

cardView.setOnClickListener{
  val extras = FragmentNavigatorExtras(
    imageView to "imageView"
  )
  findNavController().navigate(R.id.detailAction, null, null, extras)
}

override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  sharedElementEnterTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.move)

它正常工作.

这篇关于如何在导航控制器中使用共享元素过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆