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,