steelahhh
10/28/2021, 1:13 PM*TopAppBar
and scroll behavior combined with Accompanist's HorizontalPager
. As soon as I add the Scaffold
with the nestedScroll
(as per docs), the pager cannot be scrolled anymore
Code in 🧵steelahhh
10/28/2021, 1:14 PMval decayAnimationSpec = rememberSplineBasedDecay<Float>()
val scrollBehavior = remember(decayAnimationSpec) {
TopAppBarDefaults.exitUntilCollapsedScrollBehavior(decayAnimationSpec)
}
Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
LargeTopAppBar(
title = { Text(text = "LargeTopAppBar") },
scrollBehavior = scrollBehavior,
)
}
) { contentPadding ->
HorizontalPager(count = 2) {
when (it) {
0 -> LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = contentPadding,
content = {
items(100) {
Text(
modifier = Modifier
.fillParentMaxWidth()
.padding(horizontal = 24.dp, vertical = 16.dp),
text = "Item #$it"
)
}
}
)
1 -> LazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = contentPadding,
content = {
items(100) {
Text(
modifier = Modifier
.fillParentMaxWidth()
.padding(horizontal = 24.dp, vertical = 16.dp),
text = "Bunch of plain items"
)
}
}
)
}
}
}
Oleksandr Balan
11/09/2021, 12:45 PM