Android BounceInterpolator 反弹插值器 - chuwuwang/ReadingNote GitHub Wiki

class BounceInterpolator(
        private val amplitude: Double,
        private val frequency: Double
) : Interpolator {

    override fun getInterpolation(time: Float): Float = (-1 * Math.E.pow(-time / amplitude) * cos(frequency * time) + 1).toFloat()

}

amplitude: 反弹幅度, 值越高, 反弹越明显.

frequency: 跳动的频率, 较高的值会在动画时间段内产生更多的摆动.

注: Android 本身也提供了回弹插值器 BounceInterpolator, 位于 android.view.animation.BounceInterpolator, 但是不支持设置反弹的幅度和频率.

链接: https://evgenii.com/blog/spring-button-animation-on-android/