@Composable
fun Repeatable01() {
var visible by remember { mutableStateOf(true)
}
val scale by animateFloatAsState(targetValue = if (visible) 1.0f else 0.0f,animationSpec =
repeatable(iterations = 10,
animation = tween(durationMillis = 2000),
repeatMode = RepeatMode.Reverse
)
)
Column(horizontalAlignment = Alignment.Start) {
Box(
modifier = Modifier
.size(200.dp)
.graphicsLayer {
scaleX = scale
scaleY = scale
}
.background(Color.Blue),
contentAlignment = Alignment.Center
) {
Text(text = "Hello", color = Color.White)
}
}
Spacer(modifier = Modifier.height(20.dp))
Button(onClick = { visible = !visible }) {
Text(text = if (visible) "Hide" else "Show")
}
}
08-14
707
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-25