AnimatedFloat

class AnimatedFloat : BaseAnimatedValue<Float>
kotlin.Any
   ↳ androidx.animation.BaseAnimatedValue<kotlin.Float>
   ↳ androidx.animation.AnimatedFloat

This class inherits most of the functionality from BaseAnimatedValue. In addition, it tracks velocity and supports the definition of bounds. Once bounds are defined using setBounds, the animation will consider itself finished when it reaches the upper or lower bound, even when the velocity is non-zero.

Summary

Public constructors

<init>(valueHolder: ValueHolder<Float>)

This class inherits most of the functionality from BaseAnimatedValue.

Public methods

Unit
setBounds(min: Float = Float.NEGATIVE_INFINITY, max: Float = Float.POSITIVE_INFINITY)

Sets up the bounds that the animation should be constrained to.

Unit
snapTo(targetValue: Float)

Sets the current value to the target value immediately, without any animation.

Inherited functions

Extension functions

From androidx.animation
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.

From androidx.ui.foundation.animation
Unit
AnimatedFloat.fling(config: FlingConfig, startVelocity: Float)

Starts a fling animation with the specified starting velocity and fling configuration.

Properties

Float

Velocity of the current animation.

Inherited properties

Public constructors

<init>

AnimatedFloat(valueHolder: ValueHolder<Float>)

This class inherits most of the functionality from BaseAnimatedValue. In addition, it tracks velocity and supports the definition of bounds. Once bounds are defined using setBounds, the animation will consider itself finished when it reaches the upper or lower bound, even when the velocity is non-zero.

Parameters
valueHolder: ValueHolder<Float> A value holder of Float type whose value field will be updated during animations

Public methods

setBounds

fun setBounds(
    min: Float = Float.NEGATIVE_INFINITY,
    max: Float = Float.POSITIVE_INFINITY
): Unit

Sets up the bounds that the animation should be constrained to. Note that when the animation reaches the bounds it will stop right away, even when there is remaining velocity.

Parameters
min: Float = Float.NEGATIVE_INFINITY Lower bound of the animation value. Defaults to Float.NEGATIVE_INFINITY
max: Float = Float.POSITIVE_INFINITY Upper bound of the animation value. Defaults to Float.POSITIVE_INFINITY

snapTo

fun snapTo(targetValue: Float): Unit

Sets the current value to the target value immediately, without any animation.

Parameters
targetValue: Float The new target value to set value to.

Properties

velocity

var velocity: Float

Velocity of the current animation.