对象动画师剪辑视图组

问题描述 投票:0回答:1

我正在通过将 Y 方向上的视图组从其原始位置平移到顶部来创建动画。

我在 Android 13 中遇到一个奇怪的问题。将视图组移动到顶部时,视图组被剪切。我在运行 Android 10 的手机上检查过同样的情况,运行良好。

我附上两部手机的屏幕录像。

Behaviour in android 13

Behaviour in 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 布局截图。

Android Studio Layout

android animation android-animation
1个回答
0
投票

将这些设置为所有父级

ConstraintLayout
及其父级 ViewGroup:

android:clipToPadding="false"
android:clipChildren="false"

或者您可以尝试稍微增加

stepsLayout
的高度,使其与其他视图重叠:

android:elevation="2dp"
© www.soinside.com 2019 - 2024. All rights reserved.