I tried animations in Jetpack Compose. I'm facing problem in rotate animation.
It seems everything fine. But don't know why it's not working.
My code:
@Composable
private fun RotateAnimationContent() {
val isRotated = rememberSaveable { mutableStateOf(false) }
val rotationAngle by animateFloatAsState(
targetValue = if (isRotated.value) 360F else 0F,
animationSpec = tween(durationMillis = 1500,easing = FastOutLinearInEasing)
)
Column {
Box(modifier = Modifier.background(Color.Red).size(100.dp).rotate(rotationAngle))
Button(
onClick = { isRotated.value = !isRotated.value },
modifier = Modifier.padding(10.dp)
) {
Text(text = "Rotate Box")
}
}
}