Performing a transition from item in RecyclerView of Fragment to another Fragment

孤者浪人 提交于 2019-12-11 14:40:15

问题


I am trying to perform an explode transition when a user clicks on an item in a RecyclerView of a fragment that will replace the current fragment with another full-screen fragment. I have seen that the best way to implement this is through sharedElements, however, the only view that is shared between the item in the RecyclerView and the full-screen fragment is a TextView. When trying the explode transition (by using android.R.transition.explode) to expand the item up and down to make the full-screen fragment, it does not perform as expected and looks really bad. I am trying to do it by setting up an enterTransition() of the activity's window but it is not working. The code is below. I am trying to make this transition exactly as shown here: https://material.io/design/navigation/navigation-transitions.html#hierarchical-transitions. If the way I am doing this expected transition is incorrect, then how should I be implementing the transition from the link?

Fragment.kt

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val explode = Explode()
        explode.duration = 1000
        activity!!.window.enterTransition = explode 
}

来源:https://stackoverflow.com/questions/58981348/performing-a-transition-from-item-in-recyclerview-of-fragment-to-another-fragmen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!