Android 12 Developer Preview is here! Try it out, and give us your feedback!

VectorizedKeyframesSpec

class VectorizedKeyframesSpec<V : AnimationVector> : VectorizedDurationBasedAnimationSpec<V>
kotlin.Any
   ↳ androidx.compose.animation.core.VectorizedKeyframesSpec

VectorizedKeyframesSpec class manages the animation based on the values defined at different timestamps in the duration of the animation (i.e. different keyframes). Each keyframe can be provided via keyframes parameter. VectorizedKeyframesSpec allows very specific animation definitions with a precision to millisecond.

Here's an example of creating a VectorizedKeyframesSpec animation: (keyframes and KeyframesSpec.KeyframesSpecConfig could make defining key frames much more readable.)

    val delay = 120
    val startValue = AnimationVector3D(100f, 200f, 300f)
    val endValue = AnimationVector3D(200f, 100f, 0f)
    val keyframes = VectorizedKeyframesSpec<AnimationVector3D>(
         keyframes = mutableMapOf (
              0 to (startValue to LinearEasing),
              100 to (startValue to FastOutLinearInEasing)
         ),
         durationMillis = 200,
         delayMillis = delay
    )

Summary

Public constructors
<init>(keyframes: Map<Int, Pair<V, Easing>>, durationMillis: Int, delayMillis: Int = 0)

VectorizedKeyframesSpec class manages the animation based on the values defined at different timestamps in the duration of the animation (i.

Public methods
V
getValueFromNanos(playTimeNanos: Long, initialValue: V, targetValue: V, initialVelocity: V)

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

V
getVelocityFromNanos(playTimeNanos: Long, initialValue: V, targetValue: V, initialVelocity: V)

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

Inherited functions