UiMode

Function

Android
fun DeviceConfigurationOverride.Companion.UiMode(
    @UiModeType uiModeType: Int
): DeviceConfigurationOverride

A DeviceConfigurationOverride that overrides the current ui mode type.

Parameters

uiModeTypethe uiMode type to render the content under test in. This should be one of the Configuration.UI_MODE_TYPE_* values.

Returns

a DeviceConfigurationOverride that specifies the uiMode type for the content under test.

Code Examples

DeviceConfigurationOverrideUiMode

@Composable
fun DeviceConfigurationOverrideUiMode() {
    DeviceConfigurationOverride(
        DeviceConfigurationOverride.UiMode(Configuration.UI_MODE_TYPE_CAR)
    ) {
        // will be Configuration.UI_MODE_TYPE_CAR
        LocalConfiguration.current.uiMode and Configuration.UI_MODE_TYPE_MASK
    }
}