![](/img/trans.png)
[英]How to move focus from one component to another in Jetpack compose?
[英]Jetpack Compose - how to adjust the padding depending on the height of another component?
我有一個使用Modifier.wrapContentHeight()
設置的組件,其高度根據其內容具有不同的高度。 我想動態地將其他組件的填充調整到第一個組件的高度。 我試過這樣的事情:
var height = 0
val resourceContentBottomPadding = height + 16
LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(start = 16.dp, end = 16.dp, bottom = height.dp),
) { /.../ }
Column(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.onGloballyPositioned {
height = it.size.height
}
) {
if (something)
SomeComposeElement()
Button()
}
不幸的是,它沒有任何改變。
如果您將 LazyColumn 和 Column 放在祖先 Column 中並為您的 LazyColumn 設置modifier = Modifier.fillMaxWidth().weight(1f)
它只會在 Column 布局后占用空間,即總高度 - 列的高度
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.