我正在通过将 Y 方向上的视图组从其原始位置平移到顶部来创建动画。
我在 Android 13 中遇到一个奇怪的问题。将视图组移动到顶部时,视图组被剪切。我在运行 Android 10 的手机上检查过同样的情况,运行良好。
我附上两部手机的屏幕录像。
这里是动画代码。
val totalAnimationDuration = 2000L
val context = cameraUIBinding!!.stepsLayout.context
val moveOutAnimator = ObjectAnimator.ofFloat(
cameraUIBinding!!.stepsLayout,
"translationY",
-context.dpToPx(200f)
)
.apply {
duration = totalAnimationDuration
interpolator = LinearInterpolator()
repeatCount = 5
}
moveOutAnimator.start()
这是 android studio 布局截图。
将这些设置为所有父级
ConstraintLayout
及其父级 ViewGroup:
android:clipToPadding="false"
android:clipChildren="false"
或者您可以尝试稍微增加
stepsLayout
的高度,使其与其他视图重叠:
android:elevation="2dp"