有没有办法在 Jetpack Compose 的垂直滚动视图中嵌套 LazyVerticalGrid

Is there a way to nest a LazyVerticalGrid iniside a vertical scrollable view in Jetpack Compose

我正在尝试在具有可滚动内容的主屏幕中显示项目的 LazyGrid。

我试过如下设置屏幕:

@Composable
fun MainScreen(){

    ConstraintLayout(Modifier.verticalScroll(remeberScrollState())) {
    
    val (view, rowView, image, gridView) = createRefs()

    Row(){
    //view
}
    Row (){
    //rowView (a lazy row)
}
    Row() {
    //image
}
    Row() {
    //gridView
   }
 }


}

Compose 与其他视图没有问题,但是一旦包含网格视图,我就遇到了这个错误:

java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll()). If you want to add a header before the list of items please add a header as a separate item() before the main items() inside the LazyColumn scope. There are could be other reasons for this to happen: your ComposeView was added into a LinearLayout with some weight, you applied Modifier.wrapContentSize(unbounded = true) or wrote a custom layout. Please try to remove the source of infinite constraints in the hierarchy above the scrolling container.

LazyVerticalGrid 的设置如下:

list : List<Object>

LazyVerticalGrid( cells = GridCells.Fixed(2), content = {

items(list.size) { index ->

Card(){...}

}
})

有没有办法在任何可垂直滚动的布局中嵌套 LazyVerticalGrid?

简单示例:

ConstraintLayout(Modifier.verticalScroll(rememberScrollState())){
    LazyVerticalGrid( cells = GridCells.Fixed(2),Modifier.height(150.dp)){
        items(5){
            Text(text = "hello")
        }
    }
}

当列表嵌套时,内部列表需要固定高度