【发布时间】:2021-04-19 08:57:12
【问题描述】:
我想使用权重制作一个简单的喷气背包组合布局。下面是代码
Row() {
Column(
Modifier.weight(1f).background(Blue)){
Text(text = "Weight = 1", color = Color.White)
}
Column(
Modifier.weight(2f).background(Yellow)
) {
Text(text = "Weight = 2")
}
}
但是,如果我的内部视图来自其他一些可组合函数,而该函数不知道它将成为列或行的子函数,该怎么办?
Row() {
// Calling Some composable function here
}
在这种情况下,我无法访问 Modifier.weight(..) 函数,因为它认为它不在行或列范围内,因为它是一个独立的函数。
【问题讨论】:
标签: android android-jetpack-compose android-layout-weight