【发布时间】:2021-03-12 05:25:34
【问题描述】:
我有一个 MotionLayout 过渡,其中运动插值器设置了三次贝塞尔函数:
<Transition
android:id="@+id/transition01"
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
motion:motionInterpolator="cubic(.81,.1,.92,1.4)"
motion:duration="1000">
我希望在过渡结束时在动画结束时产生类似“弹簧”的效果,如下所示: https://cubic-bezier.com/#.81,.1,.92,1.4
但是在动画结束时,目标视图只是坚持最终的约束,没有做反弹效果。
我也试过motion:motionInterpolator="cubic-bezier(.81,.1,.92,1.4)",但没有成功。
有谁知道我如何使用 MotionLayout 实现这一点?感谢您提供任何线索。
这是我正在使用的版本:
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
【问题讨论】:
-
您应该说明您使用的是哪个版本的库:developer.android.com/jetpack/androidx/releases/…
-
@MorrisonChang 我在问题中添加了版本。现在是 2.0.4
-
发现 source - line 594 只是一个线性三次贝塞尔曲线,所以参数只能从 0 到 1。如果你想反弹,还有一个完整的 Android section on spring animation。
-
@MorrisonChang 谢谢。所以我知道使用 MotionLayout 是不可能的。我确实知道 Spring 动画依赖项,尽管我更喜欢在 MotionLayout 中使用它,因为它可以轻松地协调我的很多动画,而且我真的不想重写所有内容。哦,好吧...
标签: android android-motionlayout