Created
August 3, 2021 14:37
-
-
Save mattmook/06dc07b9f3454bbff764b6b8d47f99c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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