Reputation: 60081
In https://developer.android.com/jetpack/compose/animation
If you are animating changes to content size:
Use Modifier.contentSize.
However, I cannot find how to access Modifier.contentSize
and use it. Any guide?
Upvotes: 5
Views: 5734
Reputation: 4801
I think you are talking about the animateContentSize function.
Here I have an example that might help
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
// This `Column` animates its size when its content changes.
.animateContentSize()
) {
Row {
Icon(
imageVector = Icons.Default.Info,
contentDescription = null
)
// ...
}
if (expanded) { // If the expanded value is changed then the animateContentSize will be triggered
Spacer(modifier = Modifier.height(8.dp))
Text(
text = stringResource(R.string.lorem_ipsum),
textAlign = TextAlign.Justify
)
}
}
From the Jetpack Compose Animation codelab:
Upvotes: 12