gpt4 book ai didi

android - Jetpack Compose Vertical Grid 单项跨度大小

转载 作者:行者123 更新时间:2023-12-04 23:55:56 30 4
gpt4 key购买 nike

在 xml 中,您可以在 GridLayoutManager 中使用 GridLayoutManager.SpanSizeLookup 来设置单个项目的跨度大小(该项目将在行中使用多少列,例如,在 3 列的网格中,我可以将第一个项目设置为跨度大小为 3,因此它将使用网格的所有宽度),但在 Compose 中我找不到方法,垂直网格只能设置全局跨度计数和添加项目,但不能设置单个项目的跨度大小,有没有办法做到这一点?

最佳答案

Jetpack Compose 版本 1.1.0-beta03LazyVerticalGrid 引入了水平跨度。

示例代码:

val list by remember { mutableStateOf(listOf("A", "E", "I", "O", "U")) }

LazyVerticalGrid(
cells = GridCells.Fixed(2)
) {
// Spanned Item:
item(
span = {
// Replace "maxCurrentLineSpan" with the number of spans this item should take.
// Use "maxCurrentLineSpan" if you want to take full width.
GridItemSpan(maxCurrentLineSpan)
}
) {
Text("Vowels")
}

// Other items:
items(list) { item ->
Text(item)
}
}

关于android - Jetpack Compose Vertical Grid 单项跨度大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69382494/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com