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

BaseAnimatedValue

sealed class BaseAnimatedValue<T, V : AnimationVector>
kotlin.Any
   ↳ androidx.animation.BaseAnimatedValue

This is the base class for AnimatedValue. It contains all the functionality of AnimatedValue. It is intended to be used as a base class for the other classes (such as AnimatedFloat to build on top of.

Animations in this class allow and anticipate the animation target to change frequently. When the target changes as the animation is in-flight, the animation is expected to make a continuous transition to the new target.

Summary

Public methods
Unit
animateTo(targetValue: T, anim: AnimationBuilder<T> = defaultPhysicsBuilder(), onEnd: (AnimationEndReason, T) -> Unit = null)

Sets the target value, which effectively starts an animation to change the value from value to the target value.

open Unit
snapTo(targetValue: T)

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

Unit

Stops any on-going animation.

Protected methods
open Unit
checkFinished(playtime: Long)

Properties
Boolean

Indicates whether the animation is running.

T

The target of the current animation.

abstract T

Current value of the animation.

Public methods

animateTo

fun animateTo(
    targetValue: T,
    anim: AnimationBuilder<T> = defaultPhysicsBuilder(),
    onEnd: (AnimationEndReason, T) -> Unit = null
): Unit

Sets the target value, which effectively starts an animation to change the value from value to the target value. If there is already an animation in flight, this method will interrupt the ongoing animation, invoke onEnd that is associated with that animation, and start a new animation from the current value to the new target value.

Parameters
targetValue: T The new value to animate to
anim: AnimationBuilder<T> = defaultPhysicsBuilder() The animation that will be used to animate from the current value to the new target value. If unspecified, a spring animation will be used by default.
onEnd: (AnimationEndReason, T) -> Unit = null An optional callback that will be invoked when the animation finished by any reason.

snapTo

open fun snapTo(targetValue: T): Unit

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

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

stop

fun stop(): Unit

Stops any on-going animation. No op if no animation is running. Note that this method does not skip the animation value to its target value. Rather the animation will be stopped in its track.

Protected methods

checkFinished

protected open fun checkFinished(playtime: Long): Unit

Properties

isRunning

var isRunning: Boolean

Indicates whether the animation is running.

targetValue

var targetValue: T

The target of the current animation. This target will not be the same as the value of the animation, until the animation finishes un-interrupted.

value

abstract var value: T

Current value of the animation.