← Back to Compose Animation
animateContentSize
Modifier
in
Compose Animation
. Since 0.1.0-dev16Overview
Examples
Community Notes
Video
@Composable
fun AnimateContent() {
val shortText = "Hi"
val longText = "Very long text\nthat spans across\nmultiple lines"
var short by remember { mutableStateOf(true) }
Box(
modifier = Modifier
.background(
Color.Blue,
RoundedCornerShape(15.dp)
)
.clickable { short = !short }
.padding(20.dp)
.wrapContentSize()
.animateContentSize()
) {
Text(
if (short) {
shortText
} else {
longText
},
style = LocalTextStyle.current.copy(color = Color.White)
)
}
}
Next ComponentAnimatedContent →