我正在尝试向我的片段添加共享元素过渡,这将创建类似于居中徽标的顶部。我成功完成了共享元素转换,但徽标也应用了一些窗口插入。仅在共享元素转换完成后才会应用窗口插入的问题。这使得它看起来像是跳到最终位置。
我正在使用以下代码。
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)
}
有人可以帮我吗?
如何在执行共享元素转换之前先应用窗口inset,以便"跳转"不会发生?