LocalAbsoluteElevation
Property
Common
val LocalAbsoluteElevation = compositionLocalOf { 0.dp }
CompositionLocal containing the current absolute elevation provided by Surface
components. This
absolute elevation is a sum of all the previous elevations. Absolute elevation is only used for
calculating elevation overlays in dark theme, and is not used for drawing the shadow in a
Surface
. See ElevationOverlay
for more information on elevation overlays.
Code Examples
AbsoluteElevationSample
@Suppress("UNUSED_VARIABLE", "NAME_SHADOWING")
@Composable
fun AbsoluteElevationSample() {
Surface(elevation = 4.dp) {
// This will equal 4.dp
val elevation = LocalAbsoluteElevation.current
Surface(elevation = 2.dp) {
// This will equal 6.dp (4 + 2)
val elevation = LocalAbsoluteElevation.current
}
}
}