If you take a took at how screenHeightDp is defined.
The current height of the available screen space, in dp units, corresponding to screen height resource qualifier.
Apparently, It excludes the area occupied by window insets, such as the status bar, navigation bar, and cutouts.
So here is a solution I managed to solve the problem. It try to get entire screen size from WindowManager. and feed them via Modifier.requiredSize()
. Note that it is important to ignore parent constraints by using requiredSize
, otherwise it won't work. More info at https://stackoverflow.com/a/65779227/157675 .
Dialog(
properties = DialogProperties(usePlatformDefaultWidth = false),
onDismissRequest = onDismiss
) {
val context = LocalContext.current
val windowManager =
remember { context.getSystemService(Context.WINDOW_SERVICE) as WindowManager }
val metrics = DisplayMetrics().apply {
windowManager.defaultDisplay.getRealMetrics(this)
}
val (width, height) = with(LocalDensity.current) {
Pair(metrics.widthPixels.toDp(), metrics.heightPixels.toDp())
}
Column(
modifier = Modifier
.requiredSize(width, height)
.background(color = Color.Green)
) {
// ...
}
}