zoha131
09/11/2020, 9:09 PMnickbutcher
09/11/2020, 9:36 PMYann Badoual
09/11/2020, 10:32 PMcontentPadding
on the ScrollableColumn
As seen on this gif.
fun getScrollableContentPadding(density: Density): Dp {
return with(density) {
(pageSize.height + toolbarContentSize.height - scrollableContentSize.height).toDp() - AppBarSize
}.coerceAtLeast(0.dp)
}
You can retrieve the size used with the onPositioned
modifierArchie
07/10/2021, 6:41 PMBox
I tried integrating the same concept with a Scaffold
instead but immediately found out that the topBar
slot for the TopAppBar
would still be there even if I offset it, hence the LazyColumn clipping. Was just wondering whether its just not recommended to make Scaffold
work with a CollapsingToolbar
.
Here’s part of the Code:
Scaffold(
Modifier
.fillMaxSize()
// attach as a parent to the nested scroll system
.nestedScroll(nestedScrollConnection),
topBar = {
TopAppBar(
modifier = Modifier
.height(toolbarHeight)
.offset { IntOffset(x = 0, y = toolbarOffsetHeightPx.value.roundToInt()) },
title = { Text("toolbar offset is ${toolbarOffsetHeightPx.value}") }
)
}
) {
// our list with build in nested scroll support that will notify us about its scroll
LazyColumn {
items(100) { index ->
Text("I'm item $index", modifier = Modifier.fillMaxWidth().padding(16.dp))
}
}
}