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

ExponentialDecay

class ExponentialDecay : FloatDecayAnimationSpec
kotlin.Any
   ↳ androidx.animation.ExponentialDecay

This is a decay animation where the friction/deceleration is always proportional to the velocity. As a result, the velocity goes under an exponential decay. The constructor parameter, friction multiplier, can be tuned to adjust the amount of friction applied in the decay. The higher the multiplier, the higher the friction, the sooner the animation will stop, and the shorter distance the animation will travel with the same starting condition.

Summary

Public constructors
<init>(@FloatRange(0.0, 3.4E38, false) frictionMultiplier: Float = 1f, @FloatRange(0.0, 3.4E38, false) absVelocityThreshold: Float = 0.1f)

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

Public methods
Long
getDurationMillis(start: Float, startVelocity: Float)

Returns the duration of the decay animation, in milliseconds.

Float
getTarget(start: Float, startVelocity: Float)

Returns the target value of the animation based on the starting condition of the animation ( i.

Float
getValue(playTime: Long, start: Float, startVelocity: Float)

Returns the value of the animation at the given time.

Float
getVelocity(playTime: Long, start: Float, startVelocity: Float)

Returns the velocity of the animation at the given time.

Inherited extension functions
From androidx.animation
Animation<Float, AnimationVector1D>
FloatDecayAnimationSpec.createAnimation(startValue: Float, startVelocity: Float = 0f)

Creates a Animation (with a fixed start value and start velocity) that decays over time based on the given FloatDecayAnimationSpec.

Properties
Float

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

Public constructors

<init>

ExponentialDecay(
    @FloatRange(0.0, 3.4E38, false) frictionMultiplier: Float = 1f,
    @FloatRange(0.0, 3.4E38, false) absVelocityThreshold: Float = 0.1f)

This is a decay animation where the friction/deceleration is always proportional to the velocity. As a result, the velocity goes under an exponential decay. The constructor parameter, friction multiplier, can be tuned to adjust the amount of friction applied in the decay. The higher the multiplier, the higher the friction, the sooner the animation will stop, and the shorter distance the animation will travel with the same starting condition.

Public methods

getDurationMillis

fun getDurationMillis(
    start: Float,
    startVelocity: Float
): Long

Returns the duration of the decay animation, in milliseconds.

Parameters
start: Float start value of the animation
startVelocity: Float start velocity of the animation

getTarget

fun getTarget(
    start: Float,
    startVelocity: Float
): Float

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

Parameters
start: Float The start value of the animation
startVelocity: Float The start velocity of the animation

getValue

fun getValue(
    playTime: Long,
    start: Float,
    startVelocity: Float
): Float

Returns the value of the animation at the given time.

Parameters
playTime: Long The time elapsed in milliseconds since the start of the animation
start: Float The start value of the animation
startVelocity: Float The start velocity of the animation

getVelocity

fun getVelocity(
    playTime: Long,
    start: Float,
    startVelocity: Float
): Float

Returns the velocity of the animation at the given time.

Parameters
playTime: Long The time elapsed in milliseconds since the start of the animation
start: Float The start value of the animation
startVelocity: Float The start velocity of the animation

Properties

absVelocityThreshold

val absVelocityThreshold: Float

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