{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

FloatDecayAnimationSpec

public interface FloatDecayAnimationSpec

Known direct subclasses
FloatExponentialDecaySpec

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

SplineBasedFloatDecayAnimationSpec

A native Android fling curve decay.


This animation interface is intended to be stateless, just like Animation. But unlike Animation, DecayAnimation does not have an end value defined. The end value is a result of the animation rather than an input.

Summary

Public methods

abstract float

This is the absolute value of a velocity threshold, below which the animation is considered finished.

abstract long
getDurationNanos(float initialValue, float initialVelocity)

Returns the duration of the decay animation, in nanoseconds.

abstract float
getTargetValue(float initialValue, float initialVelocity)

Returns the target value of the animation based on the starting condition of the animation ( i.e. start value and start velocity).

abstract float
getValueFromNanos(
    long playTimeNanos,
    float initialValue,
    float initialVelocity
)

Returns the value of the animation at the given time.

abstract float
getVelocityFromNanos(
    long playTimeNanos,
    float initialValue,
    float initialVelocity
)

Returns the velocity of the animation at the given time.

Extension functions

default final @NonNull DecayAnimationSpec<@NonNull T>

Creates a DecayAnimationSpec from a FloatDecayAnimationSpec by applying the given FloatDecayAnimationSpec on every dimension of the AnimationVector that T converts to.

Public methods

getAbsVelocityThreshold

abstract float getAbsVelocityThreshold()

This is the absolute value of a velocity threshold, below which the animation is considered finished.

getDurationNanos

abstract long getDurationNanos(float initialValue, float initialVelocity)

Returns the duration of the decay animation, in nanoseconds.

Parameters
float initialValue

start value of the animation

float initialVelocity

start velocity of the animation

getTargetValue

abstract float getTargetValue(float initialValue, float initialVelocity)

Returns the target value of the animation based on the starting condition of the animation ( i.e. start value and start velocity).

Parameters
float initialValue

The start value of the animation

float initialVelocity

The start velocity of the animation

getValueFromNanos

abstract float getValueFromNanos(
    long playTimeNanos,
    float initialValue,
    float initialVelocity
)

Returns the value of the animation at the given time.

Parameters
long playTimeNanos

The time elapsed in milliseconds since the start of the animation

float initialValue

The start value of the animation

float initialVelocity

The start velocity of the animation

getVelocityFromNanos

abstract float getVelocityFromNanos(
    long playTimeNanos,
    float initialValue,
    float initialVelocity
)

Returns the velocity of the animation at the given time.

Parameters
long playTimeNanos

The time elapsed in milliseconds since the start of the animation

float initialValue

The start value of the animation

float initialVelocity

The start velocity of the animation

Extension functions

DecayAnimationSpecKt.generateDecayAnimationSpec

default final @NonNull DecayAnimationSpec<@NonNull T> <T extends Object> DecayAnimationSpecKt.generateDecayAnimationSpec(
    @NonNull FloatDecayAnimationSpec receiver
)

Creates a DecayAnimationSpec from a FloatDecayAnimationSpec by applying the given FloatDecayAnimationSpec on every dimension of the AnimationVector that T converts to.