Skip to content

Instantly share code, notes, and snippets.

@chenzhang2006
Created March 30, 2022 20:20
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 chenzhang2006/18cba7087129c00ace94ee8c5de28be5 to your computer and use it in GitHub Desktop.
Save chenzhang2006/18cba7087129c00ace94ee8c5de28be5 to your computer and use it in GitHub Desktop.
Animate Alpha
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