Google is committed to advancing racial equity for Black communities. See how.

Animation

interface Animation<T, V : AnimationVector>
androidx.animation.Animation

This interface provides a convenient way to query from an AnimationSpec or FloatDecayAnimationSpec: It spares the need to pass the starting conditions and in some cases ending condition for each value or velocity query, and instead only requires the play time to be passed for such queries.

The implementation of this interface should cache the starting conditions and ending conditions of animations as needed.

Note: Animation does not track the lifecycle of an animation. It merely reacts to play time change and returns the new value/velocity as a result. It can be used as a building block for more lifecycle aware animations. In contrast, AnimatedValue and TransitionAnimation are stateful and manage their own lifecycles, and subscribe/unsubscribe from an AnimationClockObservable as needed.

Summary

Public methods
abstract T
getValue(playTime: Long)

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

abstract V

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

open Boolean
isFinished(playTime: Long)

Returns whether the animation is finished at the given play time.

Extension functions
From androidx.animation
T
Animation<T, V>.getVelocity(playTime: Long)

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

Properties
abstract TwoWayConverter<T, V>

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

abstract Long

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

Public methods

getValue

abstract fun getValue(playTime: Long): T

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

Parameters
playTime: Long the play time that is used to determine the value of the animation.

getVelocityVector

abstract fun getVelocityVector(playTime: Long): V

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

Parameters
playTime: Long the play time that is used to calculate the velocity of the animation.

isFinished

open fun isFinished(playTime: Long): Boolean

Returns whether the animation is finished at the given play time.

Parameters
playTime: Long the play time used to determine whether the animation is finished.

Properties

converter

abstract val converter: TwoWayConverter<T, V>

The TwoWayConverter that will be used to convert value/velocity from any arbitrary data type to AnimationVector. This makes it possible to animate different dimensions of the data object independently (e.g. x/y dimensions of the position data).

durationMillis

abstract val durationMillis: Long

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