The second Android 11 Developer Preview is now available, test it out and share your feedback.

AnimatedFloat

abstract 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

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.

open Unit
snapTo(targetValue: Float)

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

Protected methods

open Unit
checkFinished(playtime: Long)

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.

Properties

Float

Upper bound of the animation value.

Float

Lower bound of the animation value.

Float

Inherited properties

Public constructors

<init>

AnimatedFloat(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
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

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

Protected methods

checkFinished

protected open fun checkFinished(playtime: Long): Unit

Properties

max

var max: Float

Upper bound of the animation value. When animations reach this upper bound, it will automatically stop with AnimationEndReason being AnimationEndReason.BoundReached. This bound is Float.POSITIVE_INFINITY by default. It can be adjusted via setBounds.

min

var min: Float

Lower bound of the animation value. When animations reach this lower bound, it will automatically stop with AnimationEndReason being AnimationEndReason.BoundReached. This bound is Float.NEGATIVE_INFINITY by default. It can be adjusted via setBounds.

velocity

val velocity: Float