According to https://google.github.io/accompanist/insets/ we can use a nested scroll connection to control the keyboard appearance when scrolling.
The sample code has the modern impl for a LazyColumn:
LazyColumn(
reverseLayout = true,
modifier = Modifier
.weight(1f)
.nestedScroll(connection = rememberImeNestedScrollConnection())
) {
items(listItems) { imageUrl -> ListItem(imageUrl, Modifier.fillMaxWidth())
}
}
The doc has a sample for ScrollableColumn which is no longer a thing as of beta06:
// Here we're using ScrollableColumn, but it also works with LazyColumn, etc.
ScrollableColumn(
// We use the nestedScroll modifier, passing in the
// the connection from rememberImeNestedScrollConnection()
modifier = Modifier.nestedScroll(
connection = rememberImeNestedScrollConnection()
)
) {
// list content
}
What is the equivalent for Modifier.verticalScroll()? I've tried combining it with nestedScroll() to no effect.
val imeNestedScrollConnection = rememberImeNestedScrollConnection()
Column(
modifier = modifier
.fillMaxHeight()
.fillMaxWidth()
.verticalScroll(scrollState)
.nestedScroll(imeNestedScrollConnection)
.padding(horizontal = spacing, vertical = 8.dp),
horizontalAlignment = Alignment.CenterHorizontally
) { ... }
Other things I've tried
- Changing the order of the two scroll modifiers (no difference)
- Having only the nestedScroll modifier (column no longer scrolls at all)
