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

KeyframesSpecConfig

class KeyframesSpecConfig<T>
kotlin.Any
   ↳ androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig

KeyframesSpecConfig stores a mutable configuration of the key frames, including durationMillis, delayMillis, and all the key frames. Each key frame defines what the animation value should be at a particular time. Once the key frames are fully configured, the KeyframesSpecConfig can be used to create a KeyframesSpec.

import androidx.compose.animation.core.KeyframesSpec

KeyframesSpec(
    KeyframesSpec.KeyframesSpecConfig<Float>().apply {
        0f at 0 // ms  // Optional
        0.4f at 75 // ms
        0.4f at 225 // ms
        0f at 375 // ms  // Optional
        durationMillis = 375
    }
)

Summary

Public constructors

KeyframesSpecConfig stores a mutable configuration of the key frames, including durationMillis, delayMillis, and all the key frames.

Public methods
infix KeyframesSpec.KeyframeEntity<T>
T.at(@IntRange(0) timeStamp: Int)

Adds a keyframe so that animation value will be this at time: timeStamp.

infix Unit

Adds an Easing for the interval started with the just provided timestamp.

Properties
Int

The amount of time that the animation should be delayed.

Int

Duration of the animation in milliseconds.

Public constructors

<init>

KeyframesSpecConfig()

KeyframesSpecConfig stores a mutable configuration of the key frames, including durationMillis, delayMillis, and all the key frames. Each key frame defines what the animation value should be at a particular time. Once the key frames are fully configured, the KeyframesSpecConfig can be used to create a KeyframesSpec.

import androidx.compose.animation.core.KeyframesSpec

KeyframesSpec(
    KeyframesSpec.KeyframesSpecConfig<Float>().apply {
        0f at 0 // ms  // Optional
        0.4f at 75 // ms
        0.4f at 225 // ms
        0f at 375 // ms  // Optional
        durationMillis = 375
    }
)

See Also

Public methods

at

infix fun T.at(@IntRange(0) timeStamp: Int): KeyframesSpec.KeyframeEntity<T>

Adds a keyframe so that animation value will be this at time: timeStamp. For example: 0.8f at 150 // ms

Parameters
timeStamp: Int The time in the during when animation should reach value: this
Return
an KeyframeEntity so a custom Easing can be added by with method.

with

infix fun KeyframesSpec.KeyframeEntity<T>.with(easing: Easing): Unit

Adds an Easing for the interval started with the just provided timestamp. For example: 0f at 50 with LinearEasing

import androidx.compose.animation.core.keyframes

// Use FastOutSlowInEasing for the interval from 0 to 50 ms, and LinearOutSlowInEasing for the
// time between 50 and 100ms
keyframes<Float> {
    durationMillis = 100
    0f at 0 with FastOutSlowInEasing
    1.5f at 50 with LinearOutSlowInEasing
    1f at 100
}
Parameters
easing: Easing Easing to be used for the next interval.

Properties

delayMillis

var delayMillis: Int

The amount of time that the animation should be delayed. Defaults to 0.

durationMillis

var durationMillis: Int

Duration of the animation in milliseconds. Defaults to DefaultDurationMillis