public interface UiMediaScope
A receiver scope that provides access to the properties of the current media environment. This scope is used by mediaQuery to evaluate conditions based on the device and window state.
Properties
windowPosture
public val windowPosture: Posture
The current posture of the application window.
This reflects how the window is laid out on the screen, which may be affected by the device's physical state. See Posture for possible values.
windowWidth
@get:FrequentlyChangingValue public val windowWidth: Dp
The current width of the application window.
windowHeight
@get:FrequentlyChangingValue public val windowHeight: Dp
The current height of the application window.
pointerPrecision
public val pointerPrecision: PointerPrecision
The highest-precision pointing device currently available.
This property resolves the pointer type based on all connected input devices, prioritizing higher precision (e.g., PointerPrecision.Fine takes precedence over PointerPrecision.Coarse if both are present). See PointerPrecision for all possible values.
keyboardKind
public val keyboardKind: KeyboardKind
The type of keyboard currently available or connected.
This property prioritizes a physical keyboard connection (KeyboardKind.Physical) over an on-screen soft keyboard (KeyboardKind.Virtual). If neither is detected, it returns KeyboardKind.None.
hasMicrophone
@get:Suppress("GetterSetterNames") public val hasMicrophone: Boolean
Whether the microphone is supported on the current device.
hasCamera
@get:Suppress("GetterSetterNames") public val hasCamera: Boolean
Whether the camera is supported on the current device.
viewingDistance
public val viewingDistance: ViewingDistance
The typical distance between the user and the device screen.
This property provides an estimate of the viewing distance, which can be useful for adjusting UI scale, content density, or hit target sizes for better ergonomics and readability.
Note that this is a broad categorization and does not represent a precise physical measurement. It is based on the device type and its typical usage context.
Members
Posture
public class Posture private constructor(private val value: Int)
Describes the posture of the window, typically on a foldable device.
This represents the arrangement of the window's display area in relation to physical features like hinges or folds.
Note that this describes the window's state, which may differ from the physical device posture. For example, if the device is in a half-folded state but the app is in split-screen mode on a single panel, the window posture will be Posture.Flat.
Members
Companion
public companion object
Properties
Flat
public val Flat: Posture
Represents a flat posture, where the window's display area on a foldable device is flat (either fully open or closed). It's the default posture for non-foldable devices, or when the window does not span across a hinge or fold (such as in split-screen mode on a single panel).
Tabletop
public val Tabletop: Posture
Represents a device in a semi-open state, similar to a laptop. The window spans across a horizontal fold or hinge, splitting the display area into two logical parts.
Book
public val Book: Posture
Represents a device in a semi-open state, folded similarly to an open book. The window spans across a vertical fold or hinge, splitting the display area into two logical parts.
PointerPrecision
public class PointerPrecision private constructor(private val value: Int)
Describes the precision of the available pointing devices.
Members
Companion
public companion object
Properties
Fine
public val Fine: PointerPrecision
Represents a pointing device with high precision, such as a mouse, trackpad, or stylus.
Coarse
public val Coarse: PointerPrecision
Represents a pointing device with limited precision, such as a touchscreen.
Blunt
public val Blunt: PointerPrecision
Represents a pointing device with low precision, such as a joystick.
None
public val None: PointerPrecision
Indicates that no pointing device is available.
KeyboardKind
public class KeyboardKind private constructor(private val value: Int)
Describes the kind of keyboard available.
Members
Companion
public companion object
Properties
Physical
public val Physical: KeyboardKind
Represents a physical hardware keyboard.
Virtual
public val Virtual: KeyboardKind
Represents an on-screen virtual keyboard (IME).
None
public val None: KeyboardKind
Indicates that no keyboard is currently available for input.
This state occurs when no physical keyboard is connected to the device, and the on-screen software keyboard (IME) is currently hidden or closed.
ViewingDistance
public class ViewingDistance private constructor(private val value: Int)
Describes the typical distance between the user and the screen.
Members
Companion
public companion object
Properties
Near
public val Near: ViewingDistance
Represents a device used within close range, such as a handheld phone, tablet, laptop, or desktop monitor. This is the default for most personal devices.
Medium
public val Medium: ViewingDistance
Represents a device positioned slightly further away, such as an automotive device, or a tablet in a dock mode.
Far
public val Far: ViewingDistance
Represents a device viewed from a significant distance, such as a television.