I am trying to achieve shared element transition between two FixedAspectImageView which lie under different fragments of different activity. Destination is also under NestedScollView What all is happening is just a flicker at Fragment1 with slight transition and than loading of Fragment2 in Activity2.
Since the elements lie under fragments of different activity, have tried using postponeEnterTransition() in on create of Activity2 and startPostponedEnterTransition() in onCreateView of Fragment2.
OriginLayout:
<CardView>
<LinearLayout>
<FrameLayout>
<FixedAspectImageView>
transitionName:"image"
DestinationLayout:
<FrameLayout>
<NestedScrollView>
<LinearLayout>
<FrameLayout>
<FixedAspectImageView>
transitionName:"image"
You are performing startPostponedEnterTransition()
too early: in on onCreateView
your view hasn't yet been created and laid out. Neither it is in onViewCreated()
, which is called right after onCreateView()
.
Instead, you have to wait until the view is laid out using either ViewTreeObserver
approach or plain view.post(Runnable)
, and only then perform startPostponedEnterTransition()
.