LazyColumn 错误:“不支持请求 SubcomposeLayout 布局的内部测量”

问题描述 投票:0回答:1

我收到以下错误:

java.lang.IllegalStateException:不支持请求 SubcomposeLayout 布局的内部测量。这包括构建在 SubcomposeLayout 之上的组件,例如惰性列表、BoxWithConstraints、TabRow 等。要缓解这种情况: 如果使用内部测量来实现“匹配父级”大小调整,请考虑使用自定义布局替换组件的父级,该自定义布局控制测量子级的顺序,从而不需要内部测量 向组件添加尺寸修饰符,以便快速返回查询的内在测量值。

这是我的代码:

LazyColumn(modifier = Modifier.fillMaxHeight()) {
    itemsIndexed(summaryList) { _, item ->
        Column(modifier = Modifier.fillParentMaxHeight()) {
            Text(text = item.displayName, style = TextStyle(fontWeight = FontWeight.Bold))
            Text(text = item.noteDesc)
            Divider()
        }
    }
}
android kotlin android-jetpack-compose android-jetpack-compose-lazy-column
1个回答
0
投票

使用

fillMaxWidth()
代替
fillParentMaxHeight()

© www.soinside.com 2019 - 2024. All rights reserved.