LocalOverscrollConfiguration
来禁用它:CompositionLocalProvider(
LocalOverscrollConfiguration provides null
) {
LazyColumn(Modifier.fillMaxWidth()) {
items(1000) {
Text(it.toString())
}
}
}
您还可以将其构建到您的主题中,以使其适用于整个应用程序:
@Composable
fun AppTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
val colors = if (darkTheme) {
DarkThemeColors
} else {
LightThemeColors
}
MaterialTheme(
colors = colors,
typography = typography,
shapes = shapes,
) {
CompositionLocalProvider(
LocalOverscrollConfiguration provides null,
content = content
)
}
}
p.s. 在 1.2.0-rc01 中,LocalOverScrollConfiguration
已更名为 LocalOverscrollConfiguration
对于嵌套LazyColumn
的人:
为了消除出现在嵌套内容周围的不美观的过度滚动效果,请不要忘记在其上设置userScrollEnabled = false
。