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

DecayAnimation

class DecayAnimation<T, V : AnimationVector> : Animation<T, V>
kotlin.Any
   ↳ androidx.compose.animation.core.DecayAnimation

DecayAnimation is an animation that slows down from initialVelocityVector as time goes on. DecayAnimation is stateless, and it does not have any concept of lifecycle. It serves as an animation calculation engine that supports convenient query of value/velocity given a play time. To achieve that, DecayAnimation stores all the animation related information: initialValue, initialVelocityVector, decay animation spec, typeConverter.

Note: Unless there's a need to control the timing manually, it's generally recommended to use higher level animation APIs that build on top DecayAnimation, such as Animatable.animateDecay, AnimationState.animateDecay, etc.

Summary

Public constructors
<init>(animationSpec: DecayAnimationSpec<T>, typeConverter: TwoWayConverter<T, V>, initialValue: T, initialVelocityVector: V)

DecayAnimation is an animation that slows down from initialVelocityVector as time goes on.

<init>(animationSpec: DecayAnimationSpec<T>, typeConverter: TwoWayConverter<T, V>, initialValue: T, initialVelocity: T)

DecayAnimation is an animation that slows down from initialVelocity as time goes on.

<init>(animationSpec: VectorizedDecayAnimationSpec<V>, typeConverter: TwoWayConverter<T, V>, initialValue: T, initialVelocityVector: V)

DecayAnimation is an animation that slows down from initialVelocityVector as time goes on.

Public methods
T
getValueFromNanos(playTimeNanos: Long)

Returns the value of the animation at the given play time.

V

Returns the velocity (in AnimationVector form) of the animation at the given play time.

Inherited functions
Inherited extension functions
From androidx.compose.animation.core
T
Animation<T, V>.getVelocityFromNanos(playTimeNanos: Long)

Returns the velocity of the animation at the given play time.

Properties
Long

This amount of time in nanoseconds that the animation will run before it finishes

T

V

Boolean

Whether or not the Animation represents an infinite animation.

T

This is the value that the Animation will reach when it finishes uninterrupted.

TwoWayConverter<T, V>

The TwoWayConverter that will be used to convert value/velocity from any arbitrary data type to AnimationVector.

Public constructors

<init>

DecayAnimation(
    animationSpec: DecayAnimationSpec<T>,
    typeConverter: TwoWayConverter<T, V>,