Skip to content

AnimationSpec

Configure how animations behave over time.

SpecDescription
tween()Duration-based with easing
spring()Physics-based spring animation
keyframes()Define values at specific times
snap()Instant change, no animation
infiniteRepeatable()Loops forever
repeatable()Loops N times
animateFloatAsState(
targetValue = 1f,
animationSpec = tween(
durationMillis = 300,
delayMillis = 50,
easing = FastOutSlowInEasing
)
)
animateFloatAsState(
targetValue = if (expanded) 1f else 0f,
animationSpec = spring(
dampingRatio = Spring.DampingRatioMediumBouncy,
stiffness = Spring.StiffnessLow
)
)
DampingRatioDescription
DampingRatioHighBouncy0.2 - Very bouncy
DampingRatioMediumBouncy0.5 - Medium bounce
DampingRatioLowBouncy0.75 - Low bounce
DampingRatioNoBouncy1.0 - No bounce
StiffnessDescription
StiffnessHighFast
StiffnessMediumMedium
StiffnessMediumLowMedium-slow
StiffnessLowSlow
StiffnessVeryLowVery slow
animateFloatAsState(
targetValue = 1f,
animationSpec = keyframes {
durationMillis = 1000
0f at 0 using LinearEasing
0.5f at 500
1f at 1000
}
)
EasingDescription
LinearEasingConstant speed
FastOutSlowInEasingAccelerate then decelerate (default)
FastOutLinearInEasingFast start, linear end
LinearOutSlowInEasingLinear start, slow end
EaseInOutCubicSmooth start and end