V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  od66666666  ›  全部回复第 1 页 / 共 1 页
回复总数  1
1 天前
回复了 magic3584 创建的主题 Android 请教个 Jetpack Compose 的布局问题
遇 size 不决,直接 onGloballyPositioned

Row(modifier = Modifier.fillMaxWidth()) {
val density = LocalDensity.current
var columnHeight by remember { mutableStateOf(0.dp) }
Box(
modifier = Modifier
.height(columnHeight)
.width(24.dp),
contentAlignment = Alignment.Center
) {
...
}
Spacer(Modifier.width(8.dp))
Column(modifier = Modifier
.onGloballyPositioned { layoutCoordinates ->
columnHeight =
with(density) { layoutCoordinates.size.height.toDp() }
}
.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(8.dp)) {
...
}
}
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2698 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 10ms · UTC 15:19 · PVG 23:19 · LAX 08:19 · JFK 11:19
Developed with CodeLauncher
♥ Do have faith in what you're doing.