contrastLevel

@FloatRange(from = -1.0, to = 1.0)
fun contrastLevel(context: Context, fallback: () -> Float = { 0f }): Float

Retrieve the contrast level of the device. This value can be used to adjust the colors of the theme.

It is available on Android 34 and above. On lower versions, the fallback value will be returned.

The contrast level is a float value between -1.0 and 1.0. The default value is 0.0. A value of -1.0 means that the contrast is set to the minimum value, and a value of 1.0 means that the contrast is set to the maximum value.

Return

The contrast level of the device or the fallback if not available.

Parameters

context

The context to use to retrieve the UiModeManager.

fallback

The fallback value to return if the contrast level is not available.

See also