android - 如何在 Jetpack Compose 中使用 Modifier.contentSize?
问题描述
在https://developer.android.com/jetpack/compose/animation
If you are animating changes to content size:
Use Modifier.contentSize.
但是,我找不到如何访问Modifier.contentSize
和使用它。有指南吗?
解决方案
我认为您在谈论animateContentSize函数。
这里我有一个可能有帮助的例子
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
)
}
}
来自 Jetpack Compose Animation 代码实验室:
推荐阅读
- javascript - 同时支持更多字段的过滤功能
- numpy - 将二维列数组输入二维numpy数组
- jquery - WordPress 上的 Highcharts 独立框架在更新后不再工作
- python - MATLAB 和 Keras 上的“相同”网络具有非常不同的结果
- sql-server - SQL PK删除单行很慢
- javascript - WebRTC 随机连接,无音频输出
- tensorflow-datasets - TensorFlow 中的变量类型
- javascript - 如何正确使用javascript“包含”方法来检查字符串是否包含某些字符
- mysql - MYSQL 排名与实施问题的关系
- c# - Kafka 消费者(使用 kafka-net)默认从头获取所有消息