Skip to content

Instantly share code, notes, and snippets.

@mattmook
Created August 3, 2021 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmook/06dc07b9f3454bbff764b6b8d47f99c9 to your computer and use it in GitHub Desktop.
Save mattmook/06dc07b9f3454bbff764b6b8d47f99c9 to your computer and use it in GitHub Desktop.
@Composable
fun Screen() {
val lazyListState = rememberLazyListState()
Column {
AppBar(stringResource(id = R.string.app_name), elevation = lazyListState.elevation)
LazyColumn(state = lazyListState) {
...
}
}
}
val LazyListState.elevation: Dp
get() = if (firstVisibleItemIndex == 0) {
minOf(firstVisibleItemScrollOffset.toFloat().dp, AppBarDefaults.TopAppBarElevation)
} else {
AppBarDefaults.TopAppBarElevation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment