{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

KeyframesSpec.KeyframesSpecConfig

public final class KeyframesSpec.KeyframesSpecConfig<T extends Object>


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.FastOutSlowInEasing
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.keyframes
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp

// Use FastOutSlowInEasing for the interval from 0 to 50 ms, and LinearOutSlowInEasing for the
// time between 50 and 100ms
keyframes<DpOffset> {
    durationMillis = 200
    DpOffset(0.dp, 0.dp) at 0 with LinearEasing
    DpOffset(500.dp, 100.dp) at 100 with LinearOutSlowInEasing
    DpOffset(400.dp, 50.dp) at 150
}
See also
keyframes

Summary

Public constructors

<T extends Object> KeyframesSpecConfig()

Public methods

final @NonNull KeyframesSpec.KeyframeEntity<@NonNull T>
at(@NonNull T receiver, int timeStamp)

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

final @NonNull KeyframesSpec.KeyframeEntity<@NonNull T>
atFraction(@NonNull T receiver, float fraction)

Adds a keyframe so that the animation value will be the value specified at a fraction of the total durationMillis set.

boolean
equals(Object other)
final int

The amount of time that the animation should be delayed.

final int

Duration of the animation in milliseconds.

int
final void
setDelayMillis(int delayMillis)

The amount of time that the animation should be delayed.

final void
setDurationMillis(int durationMillis)

Duration of the animation in milliseconds.

final void
with(
    @NonNull KeyframesSpec.KeyframeEntity<@NonNull T> receiver,
    @NonNull Easing easing
)

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

Public constructors

KeyframesSpecConfig

public <T extends Object> KeyframesSpecConfig()

Public methods

at

public final @NonNull KeyframesSpec.KeyframeEntity<@NonNull T> at(@NonNull T receiver, int timeStamp)

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

Parameters
int timeStamp

The time in the during when animation should reach value: this, with a minimum value of 0.

Returns
@NonNull KeyframesSpec.KeyframeEntity<@NonNull T>

an KeyframeEntity so a custom Easing can be added by with method.

atFraction

public final @NonNull KeyframesSpec.KeyframeEntity<@NonNull T> atFraction(@NonNull T receiver, float fraction)

Adds a keyframe so that the animation value will be the value specified at a fraction of the total durationMillis set. For example: 0.8f atFraction 0.50f // half of the overall duration set

Parameters
float fraction

The fraction when the animation should reach specified value.

Returns
@NonNull KeyframesSpec.KeyframeEntity<@NonNull T>

an KeyframeEntity so a custom Easing can be added by with method

equals

public boolean equals(Object other)

getDelayMillis

public final int getDelayMillis()

The amount of time that the animation should be delayed. The minimum is 0 and defaults to 0.

getDurationMillis

public final int getDurationMillis()

Duration of the animation in milliseconds. The minimum is 0 and defaults to DefaultDurationMillis

hashCode

public int hashCode()

setDelayMillis

public final void setDelayMillis(int delayMillis)

The amount of time that the animation should be delayed. The minimum is 0 and defaults to 0.

setDurationMillis

public final void setDurationMillis(int durationMillis)

Duration of the animation in milliseconds. The minimum is 0 and defaults to DefaultDurationMillis

with

public final void with(
    @NonNull KeyframesSpec.KeyframeEntity<@NonNull T> receiver,
    @NonNull Easing easing
)

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

import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.LinearOutSlowInEasing
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
@NonNull Easing easing

Easing to be used for the next interval.