Nthily
07/22/2023, 3:27 PMFrancesc
07/22/2023, 3:47 PM@Preview(widthDp = 360, heightDp = 360)
@Composable
fun IconScale() {
val animatable = remember {
Animatable(1f)
}
val scope = rememberCoroutineScope()
PlaygroundTheme {
Surface(
color = MaterialTheme.colorScheme.background
) {
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.SpaceAround,
) {
Icon(
imageVector = Icons.Default.Favorite,
modifier = Modifier.graphicsLayer {
scaleX = animatable.value
scaleY = animatable.value
},
contentDescription = null,
)
Button(
onClick = {
scope.launch {
animatable.animateTo(
targetValue = 3f,
animationSpec = tween(durationMillis = 500)
)
animatable.animateTo(
targetValue = 1f,
animationSpec = tween(durationMillis = 500)
)
}
}
) {
Text(
text = "Animate"
)
}
}
}
}
}
Francesc
07/22/2023, 4:14 PMNthily
07/22/2023, 4:45 PM