androidx.animation

Classes

AnimatedFloat

This class inherits most of the functionality from BaseAnimatedValue.

AnimatedValue

AnimatedValue is an animatable value holder.

AnimationBuilder

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.

Spring

Physics class contains a number of recommended configurations for physics animations.

TargetAnimation

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

TransitionAnimation

TransitionAnimation is responsible for animating from one set of property values (i.

TransitionDefinition

Static definitions of states and transitions.

TransitionSpec

Static specification for the transition from one state to another.

TweenBuilder

ValueHolderImpl

ValueHolderImpl is a data class that defines two fields: value (of type T) and a value interpolator.

Type-aliases

Easing

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

OnFlingEnd

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

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.

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.

Extension functions summary

For TransitionDefinition
TransitionAnimation<T>

Creates a transition animation using the transition definition.

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: OnFlingEnd? = null)

Starts a fling animation with the specified starting velocity.

Unit
AnimatedFloat.fling(startVelocity: Float, decay: DecayAnimation = ExponentialDecay(), adjustTarget: (Float) -> TargetAnimation?, onEnd: OnFlingEnd? = 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

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

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

Extension functions

createAnimation

fun <T> TransitionDefinition<T>.createAnimation(): TransitionAnimation<T>

Creates a transition animation using the transition definition. // TODO: Ripple impl needs to pass the ambient here clock, then we can remove this function.

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: OnFlingEnd? = 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: OnFlingEnd? = 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: OnFlingEnd? = 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: OnFlingEnd? = null An optional callback that will be invoked when the animation finished by any reason.