AnimatedFloat

class AnimatedFloat : BaseAnimatedValue<Float, AnimationVector1D>
kotlin.Any
   ↳ androidx.animation.BaseAnimatedValue<kotlin.Float, androidx.animation.AnimationVector1D>
   ↳ 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: OnAnimationEnd? = null)

Starts a fling animation with the specified starting velocity.

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

Inherited extension functions

From androidx.compose
operator T

IMPORTANT: This global operator is TEMPORARY, and should be removed whenever an answer for contextual composers is reached.

Properties

Float

Inherited properties

Public constructors

<init>

AnimatedFloat(
    initVal: Float,
    clock: AnimationClockObservable)

<init>

AnimatedFloat(valueHolder: ValueHolder<Float>)

<init>

AnimatedFloat(
    valueHolder: ValueHolder<Float>,
    clock: AnimationClockObservable)

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
clock: AnimationClockObservable An animation clock observable controlling the progression of the animated value

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

val velocity: Float