Jetpack Compose LazyVerticalGrid设置项宽(span size类似stickyHeader,占满整行)

来源:Does Jetpack Compose's LazyVerticalGrid have span strategy

        Jetpack Compose 版本 > 1.1.0-beta03
        import androidx.compose.foundation.lazy.grid.GridItemSpan

        LazyVerticalGrid(
            columns = GridCells.Fixed(2),
            state = gridState
        ) {
            gridData?.let { it ->
                items(it) {
                    // data
                }
                
                // 自定义项宽,我这里为2
                item(
                    span = { GridItemSpan(2) },
                    content = {
                        Column(
                            modifier = Modifier
                                .fillMaxWidth()
                                .padding(top = 53.dp, bottom = 32.dp),
                            horizontalAlignment = Alignment.CenterHorizontally,
                            verticalArrangement = Arrangement.Center
                        ) {
                            UText(text = "没有更多内容了~")
                        }
                    }
                )
            }
        }
posted @ 2022-06-14 17:22  李振欣  阅读(651)  评论(0编辑  收藏  举报