Created
March 30, 2022 20:20
-
-
Save chenzhang2006/18cba7087129c00ace94ee8c5de28be5 to your computer and use it in GitHub Desktop.
Animate Alpha
This file contains 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 backdropState = rememberBackdropScaffoldState(BackdropValue.Concealed) | |
val offset by backdropState.offset | |
val halfHeightDp = LocalConfiguration.current.screenHeightDp / 2 | |
val halfHeightPx = with(LocalDensity.current) { halfHeightDp.dp.toPx() } | |
//... | |
// Current alpha for vertical list | |
val verticalListAlpha = ((halfHeightPx - offset) / halfHeightPx).coerceIn(0f..1f) | |
// Current alpha for horizontal list | |
val horizontalListAlpha = (offset / halfHeightPx).coerceIn(0f..1f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment