When we show a Dialog
/AlertDialog
in Jetpack Compose the background seems to be a bit dark, is there a way to adjust the background alpha or make it transparent?
For eg: The White background in this image is turned into Dark grey when the dialog is shown.
You can make it easily like this:
Dialog(onDismissRequest = {}) {
(LocalView.current.parent as DialogWindowProvider)?.window?.setDimAmount(0f)
// dialog content here...
}
I was try with Dialog and no way to clear flag WindowManager.LayoutParams.FLAG_DIM_BEHIND.
You can try to use Popup to replace Dialog, everything work good for me.
Popup(
onDismissRequest = {},
properties = PopupProperties(
focusable = true,
dismissOnBackPress = false,
dismissOnClickOutside = false,
excludeFromSystemGesture = true,
)
) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.fillMaxSize()
.background(Color.Transparent)
) {
// Your content code is here
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With