I am trying to add a shared element transition to my fragment which will create something like a centered logo to top. I did this successfully with shared element transition but the logo also applies some window inset. The problem in that only after the shared element transition finished does the window inset gets applied. This make it looks like the views jump to their final position.
I am using the code below.
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = layoutInflater?.inflate(R.layout.onboarding_layout, container, false)
return view
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
ViewCompat.setOnApplyWindowInsetsListener(appimageviewLogo) { view, insets ->
val params = view.layoutParams as ViewGroup.MarginLayoutParams
params.topMargin = params.topMargin + insets.systemWindowInsetTop
insets
}
ViewCompat.setOnApplyWindowInsetsListener(appbuttonSkip) { view, insets ->
val params = view.layoutParams as ViewGroup.MarginLayoutParams
params.bottomMargin = params.bottomMargin + insets.systemWindowInsetBottom
insets.consumeSystemWindowInsets()
}
ViewCompat.requestApplyInsets(appimageviewLogo)
ViewCompat.requestApplyInsets(appbuttonSkip)
}
can someone help me here?
How can I apply the window inset first before performing the Shared element transition so the "jumping" wont occur?