I enabled `edgeToEdge()` in android I have a simpl...
# compose
v
I enabled
edgeToEdge()
in android I have a simple setup of a Scaffold, with app bar and bottom nav, and a lazy column in between I have
TopAppBarDefaults.enterAlwaysScrollBehavior()
applied, now whats happening is when app bar is hidden, it takes the space of the status bar, hence the Lazy Column does not scroll over the status bar ? Any way to fix this If i remove the app bar it works fine
a
TopAppBar's default window insets include status bar (WindowInsetsSides.Top). Removing it is not enough to get you what you want. The way we've done it is to have our own Layout and place AppBar content (icons, text, actions, etc) with a y offset equal to status bar height.
v
@ascii Can you share a sample code snippet if possible?
@ascii I tried this and it worked
Copy code
val topPadding by derivedStateOf {
    if(scrollBehavior?.state?.collapsedFraction == 1f) 0.dp else 32.dp
}
val padding by animateDpAsState(
    targetValue = topPadding,
    animationSpec = tween()
)
TopAppBar(
    scrollBehavior = scrollBehavior,
    windowInsets = WindowInsets(0.dp, padding, 0.dp, 0.dp),