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

SplineBasedFloatDecayAnimationSpec

public final class SplineBasedFloatDecayAnimationSpec implements FloatDecayAnimationSpec


A native Android fling curve decay.

Summary

Public constructors

Public methods

float

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

long
getDurationNanos(float initialValue, float initialVelocity)

Returns the duration of the decay animation, in nanoseconds.

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).

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

Returns the value of the animation at the given time.

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

Returns the velocity of the animation at the given time.

Public constructors

SplineBasedFloatDecayAnimationSpec

public SplineBasedFloatDecayAnimationSpec(@NonNull Density density)
Parameters
@NonNull Density density

density of the display

Public methods

getAbsVelocityThreshold

public float getAbsVelocityThreshold()

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

getDurationNanos

public 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

public 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

public 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

public 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