InfiniteTransition
Create infinite animations that run continuously.
Basic Usage
Section titled “Basic Usage”val infiniteTransition = rememberInfiniteTransition(label = "infinite")
// Pulsing animationval scale by infiniteTransition.animateFloat( initialValue = 1f, targetValue = 1.2f, animationSpec = infiniteRepeatable( animation = tween(1000), repeatMode = RepeatMode.Reverse ), label = "scale")
// Rotating animationval rotation by infiniteTransition.animateFloat( initialValue = 0f, targetValue = 360f, animationSpec = infiniteRepeatable( animation = tween(2000, easing = LinearEasing), repeatMode = RepeatMode.Restart ), label = "rotation")
// Color animationval color by infiniteTransition.animateColor( initialValue = Color.Red, targetValue = Color.Blue, animationSpec = infiniteRepeatable( animation = tween(1000), repeatMode = RepeatMode.Reverse ), label = "color")
Box( Modifier .scale(scale) .rotate(rotation) .background(color) .size(100.dp))RepeatMode
Section titled “RepeatMode”| Mode | Description |
|---|---|
RepeatMode.Restart | Jump back to initial value |
RepeatMode.Reverse | Animate back to initial value |