ScreenSize

class ScreenSize(val heightDp: Dp, val widthDp: Dp)

Immutable class representing screen dimensions in density-independent pixels.

This class provides a convenient way to access screen size information within Compose UI components, allowing for responsive design implementations.

@Composable
fun ResponsiveLayout() {
val screenSize = rememberScreenSize()

if (screenSize.widthDp 600.dp) {
// Tablet layout
TabletLayout()
} else {
// Phone layout
PhoneLayout()
}
}

Constructors

Link copied to clipboard
constructor(heightDp: Dp, widthDp: Dp)

Properties

Link copied to clipboard

Screen height in density-independent pixels

Link copied to clipboard
val widthDp: Dp

Screen width in density-independent pixels