Last active
August 3, 2021 14:44
-
-
Save mattmook/2599c405d3bab897163f67e5dd13592b 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
val LazyListState.elevation: Dp | |
get() = if (firstVisibleItemIndex == 0) { | |
// For the first element, use the minimum of scroll offset and default elevation | |
// i.e. a value between 0 and 4.dp | |
minOf(firstVisibleItemScrollOffset.toFloat().dp, AppBarDefaults.TopAppBarElevation) | |
} else { | |
// If not the first element, always set elevation and show the shadow | |
AppBarDefaults.TopAppBarElevation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment