AnimationSpec
Configure how animations behave over time.
AnimationSpec Types
Section titled “AnimationSpec Types”| Spec | Description |
|---|---|
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 |
Tween Animation
Section titled “Tween Animation”animateFloatAsState( targetValue = 1f, animationSpec = tween( durationMillis = 300, delayMillis = 50, easing = FastOutSlowInEasing ))Spring Animation
Section titled “Spring Animation”animateFloatAsState( targetValue = if (expanded) 1f else 0f, animationSpec = spring( dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow ))Spring Constants
Section titled “Spring Constants”| DampingRatio | Description |
|---|---|
DampingRatioHighBouncy | 0.2 - Very bouncy |
DampingRatioMediumBouncy | 0.5 - Medium bounce |
DampingRatioLowBouncy | 0.75 - Low bounce |
DampingRatioNoBouncy | 1.0 - No bounce |
| Stiffness | Description |
|---|---|
StiffnessHigh | Fast |
StiffnessMedium | Medium |
StiffnessMediumLow | Medium-slow |
StiffnessLow | Slow |
StiffnessVeryLow | Very slow |
Keyframes Animation
Section titled “Keyframes Animation”animateFloatAsState( targetValue = 1f, animationSpec = keyframes { durationMillis = 1000 0f at 0 using LinearEasing 0.5f at 500 1f at 1000 })Easing Types
Section titled “Easing Types”| Easing | Description |
|---|---|
LinearEasing | Constant speed |
FastOutSlowInEasing | Accelerate then decelerate (default) |
FastOutLinearInEasing | Fast start, linear end |
LinearOutSlowInEasing | Linear start, slow end |
EaseInOutCubic | Smooth start and end |