KeyframesBuilder

class KeyframesBuilder<T> : DurationBasedAnimationBuilder<T>
kotlin.Any
   ↳ androidx.animation.AnimationBuilder<T>
   ↳ androidx.animation.DurationBasedAnimationBuilder<T>
   ↳ androidx.animation.KeyframesBuilder

KeyframesBuilder creates a Keyframes animation. Keyframes animation based on the values defined at different timestamps in the duration of the animation (i.e. different keyframes). Each keyframe can be defined using at. Keyframes allows very specific animation definitions with a precision to millisecond.

import androidx.animation.KeyframesBuilder

KeyframesBuilder<Float>().apply {
    0f at 0 // ms  // Optional
    duration = 375
    0.4f at 75 // ms
    0.4f at 225 // ms
    0f at 375 // ms  // Optional
}
You can also provide a custom Easing for the interval with use of with function appliedfor the interval starting keyframe.
import androidx.animation.KeyframesBuilder

// Use FastOutSlowInEasing for the interval from 0 to 100 ms.
KeyframesBuilder<Float>().apply {
    duration = 100
    0f at 0 with FastOutSlowInEasing
    1f at 100
}

Summary

Nested classes

inner

Holder class for building a keyframes animation.

Public constructors

KeyframesBuilder creates a Keyframes animation.

Public methods

infix KeyframesBuilder.KeyframeEntity<T, T>
T.at(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.

Inherited extension functions

From androidx.compose
operator T

IMPORTANT: This global operator is TEMPORARY, and should be removed whenever an answer for contextual composers is reached.

Inherited properties

Public constructors

<init>

KeyframesBuilder()

KeyframesBuilder creates a Keyframes animation. Keyframes animation based on the values defined at different timestamps in the duration of the animation (i.e. different keyframes). Each keyframe can be defined using at. Keyframes allows very specific animation definitions with a precision to millisecond.

import androidx.animation.KeyframesBuilder

KeyframesBuilder<Float>().apply {
    0f at 0 // ms  // Optional
    duration = 375
    0.4f at 75 // ms
    0.4f at 225 // ms
    0f at 375 // ms  // Optional
}
You can also provide a custom Easing for the interval with use of with function appliedfor the interval starting keyframe.
import androidx.animation.KeyframesBuilder

// Use FastOutSlowInEasing for the interval from 0 to 100 ms.
KeyframesBuilder<Float>().apply {
    duration = 100
    0f at 0 with FastOutSlowInEasing
    1f at 100
}

Public methods

at

infix fun T.at(timeStamp: Int): KeyframesBuilder.KeyframeEntity<T, T>

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

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 KeyframesBuilder.KeyframeEntity<T, T>.with(easing: Easing): Unit

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

import androidx.animation.KeyframesBuilder

// Use FastOutSlowInEasing for the interval from 0 to 100 ms.
KeyframesBuilder<Float>().apply {
    duration = 100
    0f at 0 with FastOutSlowInEasing
    1f at 100
}
Parameters
easing: Easing Easing to be used for the next interval.