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

FloatTweenSpec

class FloatTweenSpec : FloatAnimationSpec
kotlin.Any
   ↳ androidx.animation.FloatTweenSpec

FloatTweenSpec animates a Float value from any start value to any end value using a provided easing function. The animation will finish within the duration time. Unless a delay is specified, the animation will start right away.

Summary

Public constructors
<init>(duration: Int = DefaultDurationMillis, delay: Int = 0, easing: Easing = FastOutSlowInEasing)

FloatTweenSpec animates a Float value from any start value to any end value using a provided easing function.

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

Calculates the duration of an animation.

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

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

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

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

Inherited functions
Properties
Int

the amount of time the animation will wait before it starts running.

Int

the amount of time (in milliseconds) the animation will take to finish.

Public constructors

<init>

FloatTweenSpec(
    duration: Int = DefaultDurationMillis,
    delay: Int = 0,
    easing: Easing = FastOutSlowInEasing)

FloatTweenSpec animates a Float value from any start value to any end value using a provided easing function. The animation will finish within the duration time. Unless a delay is specified, the animation will start right away.

Parameters
duration: Int = DefaultDurationMillis the amount of time (in milliseconds) the animation will take to finish. Defaults to DefaultDuration
delay: Int = 0 the amount of time the animation will wait before it starts running. Defaults to 0.
easing: Easing = FastOutSlowInEasing the easing function that will be used to interoplate between the start and end value of the animation. Defaults to FastOutSlowInEasing.

Public methods

getDurationMillis

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

Calculates the duration of an animation. For duration-based animations, this will return the pre-defined duration. For physics-based animations, the duration will be estimated based on the physics configuration (such as spring stiffness, damping ratio, visibility threshold) as well as the start, end values, and startVelocity.

Note: this may be a computation that is expensive - especially with spring based animations

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

getValue

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

Calculates the value of the animation at given the playtime, with the provided start/end values, and start velocity.

Parameters
playTime: Long time since the start of the animation
start: Float start value of the animation
end: Float end value of the animation
startVelocity: Float start velocity of the animation

getVelocity

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

Calculates the velocity of the animation at given the playtime, with the provided start/end values, and start velocity.

Parameters
playTime: Long time since the start of the animation
start: Float start value of the animation
end: Float end value of the animation
startVelocity: Float start velocity of the animation

Properties

delay

val delay: Int

the amount of time the animation will wait before it starts running. Defaults to 0.

duration

val duration: Int

the amount of time (in milliseconds) the animation will take to finish. Defaults to DefaultDuration