shared-element-transitions icon indicating copy to clipboard operation
shared-element-transitions copied to clipboard

Return transition doesn't work

Open MHKalantarian opened this issue 5 years ago • 1 comments

I have nested fragments inside a fragment and it works perfect when I enter the second fragment. But when I pop back stack to return to the first fragment it just normally returns without any animation or move or anything, like no shared elements ever defined. Also I'm using cardview for my recycler items layout.

MHKalantarian avatar Dec 29 '18 12:12 MHKalantarian

i know it's too late but maybe this be useful, so just add this to fragmentA(which list is there):

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

         postponeEnterTransition()
        val parentView = view.parent as ViewGroup
        parentView.viewTreeObserver
            .addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
                override fun onPreDraw(): Boolean {
                    parentView.viewTreeObserver.removeOnPreDrawListener(this)
                     startPostponedEnterTransition()
                    return true
                }
            })
        super.onViewCreated(view, savedInstanceState)
 


    }

razaghimahdi avatar Oct 31 '21 16:10 razaghimahdi