androidx.animation

Classes

AnimatedFloat

This class inherits most of the functionality from BaseAnimatedValue.

AnimatedValue

AnimatedValue is an animatable value holder.

AnimationBuilder

Animation builder for creating an animation that animates a value of type T.

AnimationVector

AnimationVector class that is the base class of AnimationVector1D, AnimationVector2D, AnimationVector3D and AnimationVector4D.

AnimationVector1D

This class defines a 1D vector.

AnimationVector2D

This class defines a 2D vector that contains two Float values for the two dimensions.

AnimationVector3D

This class defines a 3D vector that contains three Float value fields for the three dimensions.

AnimationVector4D

This class defines a 4D vector that contains four Float fields for its four dimensions.

BaseAnimatedValue

This is the base class for AnimatedValue.

BaseAnimationClock

Base implementation for the AnimationClockObservable that handles the subscribing and unsubscribing logic that would be common for all custom animation clocks.

CubicBezierEasing

A cubic polynomial easing.

DefaultAnimationClock

Default Choreographer based clock that pushes a new frame to all subscribers on each Choreographer tick, until all subscribers have unsubscribed.

DurationBasedAnimationBuilder

Base class for an AnimationBuilder to create animations based on a fixed duration.

ExponentialDecay

This is a decay animation where the friction/deceleration is always proportional to the velocity.

FloatPropKey

Built-in property key for Float properties.

IntPropKey

Built-in property key for Int properties.

KeyframesBuilder

KeyframesBuilder creates a Keyframes animation.

ManualAnimationClock

A custom clock whose frame time can be manually updated via mutating clockTimeMillis.

PhysicsBuilder

PhysicsBuilder takes in the configuration of a spring as its constructor parameters.

RepeatableBuilder

Used for creating repeated animations where each iteration is defined by one of the duration based animations like TweenBuilder or KeyframesBuilder.

SnapBuilder

Builds Snap animation for immediately switching the animating value to the end value.

TargetAnimation

TargetAnimation class defines how to animate to a given target value.

TransitionAnimation

TransitionAnimation is the underlying animation used in androidx.ui.animation.Transition for animating from one set of property values (i.

TransitionDefinition

TransitionDefinition contains all the animation related configurations that will be used in a state-based transition.

TransitionSpec

Static specification for the transition from one state to another.

TweenBuilder

TweenBuilder builds a tween animation that animates from start to end value, based on an easing curve within the given duration.

Type-aliases

Easing

Easing is a way to adjust an animation’s fraction.

OnAnimationEnd

Typealias for lambda that will be invoked when fling animation ends.

Enums

AnimationEndReason

Possible reasons with which DynamicTargetAnimation can finish

InterruptionHandling

Top-level constants summary

const Boolean

const Int

The default duration used in Animations.

const Int

Used as a iterations count for RepeatableBuilder to create an infinity repeating animation.

Top-level functions summary

AnimatedFloat

Factory method for creating an AnimatedFloat object, and initialize the value field to initVal.

AnimatedValue<T, V>
AnimatedValue(initVal: T, typeConverter: TwoWayConverter<T, V>, clock: AnimationClockObservable)

Factory method for creating an AnimatedValue object, and initialize the value field to initVal.

AnimatedValue<V, V>

Factory method for creating an AnimatedVector object, and initialize the value field to initVal.

AnimationVector1D

Factory method to create an AnimationVector1D

AnimationVector2D

Factory method to create an AnimationVector2D

AnimationVector3D
AnimationVector(v1: Float, v2: Float, v3: Float)

Factory method to create an AnimationVector3D

AnimationVector4D
AnimationVector(v1: Float, v2: Float, v3: Float, v4: Float)

Factory method to create an AnimationVector4D

TwoWayConverter<T, V>
TwoWayConverter(convertToVector: (T) -> V, convertFromVector: (V) -> T)

Factory method to create a TwoWayConverter that converts a type T from and to an AnimationVector type.

Long
estimateAnimationDurationMillis(stiffness: Float, dampingRatio: Float, initialVelocity: Float, initialDisplacement: Float, delta: Float)

Returns the estimated time that the spring will last be at delta

Long
estimateAnimationDurationMillis(stiffness: Double, dampingRatio: Double, initialVelocity: Double, initialDisplacement: Double, delta: Double)

Returns the estimated time that the spring will last be at delta

Long
estimateAnimationDurationMillis(springConstant: Double, dampingCoefficient: Double, mass: Double, initialVelocity: Double, initialDisplacement: Double, delta: Double)

Returns the estimated time that the spring will last be at delta

TransitionDefinition<T>

Creates a TransitionDefinition using the init function to initialize it.

Top-level properties summary

CubicBezierEasing

Elements exiting a screen use acceleration easing, where they start at rest and end at peak velocity.

CubicBezierEasing

Elements that begin and end at rest use this standard easing.

TwoWayConverter<Float, AnimationVector1D>

A TwoWayConverter that converts Float from and to AnimationVector1D

TwoWayConverter<Int, AnimationVector1D>

A TwoWayConverter that converts Int from and to AnimationVector1D

Easing

It returns fraction unmodified.

CubicBezierEasing

Incoming elements are animated using deceleration easing, which starts a transition at peak velocity (the fastest point of an element’s movement) and ends at rest.

() -> AnimationClockObservable

Extension functions summary

For TransitionDefinition
TransitionAnimation<T>

Creates a transition animation using the transition definition and the given clock.

For AnimatedFloat
Unit
AnimatedFloat.fling(startVelocity: Float, decay: DecayAnimation = ExponentialDecay(), onEnd: OnAnimationEnd? = null)

Starts a fling animation with the specified starting velocity.

Unit
AnimatedFloat.fling(startVelocity: Float, decay: DecayAnimation = ExponentialDecay(), adjustTarget: (Float) -> TargetAnimation?, onEnd: OnAnimationEnd? = null)

Starts a fling animation with the specified starting velocity.

Top-level constants

DEBUG

const val DEBUG: Boolean
Value: false

DefaultDuration

const val DefaultDuration: Int

The default duration used in Animations.

Value: 300

Infinite

const val Infinite: Int

Used as a iterations count for RepeatableBuilder to create an infinity repeating animation.

Value: Int.MAX_VALUE

Top-level functions

AnimatedFloat

fun AnimatedFloat(
    initVal: Float,
    clock: AnimationClockObservable
): AnimatedFloat

Factory method for creating an AnimatedFloat object, and initialize the value field to initVal.

Parameters
initVal: Float Initial value to initialize the animation to.
clock: AnimationClockObservable The animation clock used to drive the animation.

AnimatedValue

fun <T, V : AnimationVector> AnimatedValue(
    initVal: T,
    typeConverter: TwoWayConverter<T, V>,
    clock: AnimationClockObservable
): AnimatedValue<T, V>

Factory method for creating an AnimatedValue object, and initialize the value field to initVal.

Parameters
initVal: T Initial value to initialize the animation to.
typeConverter: TwoWayConverter<T, V> Converter for converting value type T to AnimationVector, and vice versa
clock: AnimationClockObservable The animation clock used to drive the animation.

AnimatedVector

fun <V : AnimationVector> AnimatedVector(
    initVal: V,
    clock: AnimationClockObservable
): AnimatedValue<V, V>

Factory method for creating an AnimatedVector object, and initialize the value field to initVal.

Parameters
initVal: V Initial value to initialize the animation to.
clock: AnimationClockObservable The animation clock used to drive the animation.

AnimationVector

fun AnimationVector(v1: Float): AnimationVector1D

Factory method to create an AnimationVector1D

Parameters
v1: Float value to set on the value field of AnimationVector1D

AnimationVector

fun AnimationVector(
    v1: Float,
    v2: Float
): AnimationVector2D

Factory method to create an AnimationVector2D

Parameters
v1: Float value to set on the first dimension
v2: Float value to set on the second dimension

AnimationVector

fun AnimationVector(
    v1: Float,
    v2: Float,
    v3: Float
): AnimationVector3D

Factory method to create an AnimationVector3D

Parameters
v1: Float value to set on the first dimension
v2: Float value to set on the second dimension
v3: Float value to set on the third dimension

AnimationVector

fun AnimationVector(
    v1: Float,
    v2: Float,
    v3: Float,
    v4: Float
): AnimationVector4D

Factory method to create an AnimationVector4D

Parameters
v1: Float value to set on the first dimension
v2: Float value to set on the second dimension
v3: Float value to set on the third dimension
v4: Float value to set on the fourth dimension

TwoWayConverter

fun <T, V : AnimationVector> TwoWayConverter(
    convertToVector: (T) -> V,
    convertFromVector: (V) -> T
): TwoWayConverter<T, V>

Factory method to create a TwoWayConverter that converts a type T from and to an AnimationVector type.

Parameters
convertToVector: (T) -> V converts from type T to AnimationVector
convertFromVector: (V) -> T converts from AnimatedVector to type T

estimateAnimationDurationMillis

fun estimateAnimationDurationMillis(
    stiffness: Float,
    dampingRatio: Float,
    initialVelocity: Float,
    initialDisplacement: Float,
    delta: Float
): Long

Returns the estimated time that the spring will last be at delta

estimateAnimationDurationMillis

fun estimateAnimationDurationMillis(
    stiffness: Double,
    dampingRatio: Double,
    initialVelocity: Double,
    initialDisplacement: Double,
    delta: Double
): Long

Returns the estimated time that the spring will last be at delta

estimateAnimationDurationMillis

fun estimateAnimationDurationMillis(
    springConstant: Double,
    dampingCoefficient: Double,
    mass: Double,
    initialVelocity: Double,
    initialDisplacement: Double,
    delta: Double
): Long

Returns the estimated time that the spring will last be at delta

transitionDefinition

fun <T> transitionDefinition(init: TransitionDefinition<T>.() -> Unit): TransitionDefinition<T>

Creates a TransitionDefinition using the init function to initialize it.

Parameters
init: TransitionDefinition<T>.() -> Unit Initialization function for the TransitionDefinition

Top-level properties

FastOutLinearInEasing

val FastOutLinearInEasing: CubicBezierEasing

Elements exiting a screen use acceleration easing, where they start at rest and end at peak velocity.

This is equivalent to the Android FastOutLinearInInterpolator

FastOutSlowInEasing

val FastOutSlowInEasing: CubicBezierEasing

Elements that begin and end at rest use this standard easing. They speed up quickly and slow down gradually, in order to emphasize the end of the transition.

Standard easing puts subtle attention at the end of an animation, by giving more time to deceleration than acceleration. It is the most common form of easing.

This is equivalent to the Android FastOutSlowInInterpolator

FloatToVectorConverter

val FloatToVectorConverter: TwoWayConverter<Float, AnimationVector1D>

A TwoWayConverter that converts Float from and to AnimationVector1D

IntToVectorConverter

val IntToVectorConverter: TwoWayConverter<Int, AnimationVector1D>

A TwoWayConverter that converts Int from and to AnimationVector1D

LinearEasing

val LinearEasing: Easing

It returns fraction unmodified. This is useful as a default value for cases where a Easing is required but no actual easing is desired.

LinearOutSlowInEasing

val LinearOutSlowInEasing: CubicBezierEasing

Incoming elements are animated using deceleration easing, which starts a transition at peak velocity (the fastest point of an element’s movement) and ends at rest.

This is equivalent to the Android LinearOutSlowInInterpolator

rootAnimationClockFactory

var rootAnimationClockFactory: () -> AnimationClockObservable

Extension functions

createAnimation

fun <T> TransitionDefinition<T>.createAnimation(
    clock: AnimationClockObservable,
    initState: T? = null
): TransitionAnimation<T>

Creates a transition animation using the transition definition and the given clock.

Parameters
clock: AnimationClockObservable The clock source for animation to get frame time from.

fling

fun AnimatedFloat.fling(
    startVelocity: Float,
    decay: DecayAnimation = ExponentialDecay(),
    onEnd: OnAnimationEnd? = null
): Unit

Starts a fling animation with the specified starting velocity.

Parameters
startVelocity: Float Starting velocity of the fling animation
decay: DecayAnimation = ExponentialDecay() The decay animation used for slowing down the animation from the starting velocity
onEnd: OnAnimationEnd? = null An optional callback that will be invoked when this fling animation is finished.

fling

fun AnimatedFloat.fling(
    startVelocity: Float,
    decay: DecayAnimation = ExponentialDecay(),
    adjustTarget: (Float) -> TargetAnimation?,
    onEnd: OnAnimationEnd? = null
): Unit

Starts a fling animation with the specified starting velocity.

Parameters
startVelocity: Float Starting velocity of the fling animation
adjustTarget: (Float) -> TargetAnimation? A lambda that takes in the projected destination based on the decay animation, and returns a nullable TargetAnimation object that contains a new destination and an animation to animate to the new destination. This lambda should return null when the original target is respected.
decay: DecayAnimation = ExponentialDecay() The decay animation used for slowing down the animation from the starting velocity
onEnd: OnAnimationEnd? = null An optional callback that will be invoked when the animation finished by any reason.