DialogProperties


Properties used to customize the behavior of a Dialog.

Summary

Public constructors

android
DialogProperties(
    dismissOnBackPress: Boolean,
    dismissOnClickOutside: Boolean,
    usePlatformDefaultWidth: Boolean
)
Cmn
android
DialogProperties(
    dismissOnBackPress: Boolean,
    dismissOnClickOutside: Boolean,
    securePolicy: SecureFlagPolicy,
    usePlatformDefaultWidth: Boolean,
    decorFitsSystemWindows: Boolean,
    windowTitle: String,
    windowType: Int,
    windowToken: IBinder?,
    blurBehindRadius: Dp,
    backgroundBlurRadius: Dp,
    scrimAlpha: Float,
    windowShape: Shape?
)
android

Public functions

open operator Boolean
equals(other: Any?)
android
open Int
android

Public properties

Dp

Blurs the screen behind the window within the bounds of the window.

android
Dp

Blurs the screen behind the window.

android
Boolean

Sets WindowCompat.setDecorFitsSystemWindows value.

android
Boolean

whether the popup can be dismissed by pressing the back or escape buttons on Android or the escape key on desktop.

Cmn
android
Boolean

whether the dialog can be dismissed by clicking outside the dialog's bounds.

Cmn
android
Float

The opacity of the scrim (also known as dimming) applied behind the dialog window.

android
SecureFlagPolicy

Policy for setting WindowManager.LayoutParams.FLAG_SECURE on the dialog's window.

android
Boolean

Whether the width of the dialog's content should be limited to the platform default, which is smaller than the screen width.

Cmn
android
Shape?

The Shape applied to the underlying native dialog window background.

android
String

Title to be set on the dialog's window.

android
IBinder?

An optional android.os.IBinder to be used as the window token for the dialog window.

android
Int

An optional android.view.WindowManager.LayoutParams.type to apply to the dialog's underlying android.view.Window.

android

Public constructors

DialogProperties

DialogProperties()

DialogProperties

DialogProperties(
    dismissOnBackPress: Boolean = true,
    dismissOnClickOutside: Boolean = true,
    usePlatformDefaultWidth: Boolean = true
)

DialogProperties

DialogProperties(
    dismissOnBackPress: Boolean = true,
    dismissOnClickOutside: Boolean = true,
    securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit,
    usePlatformDefaultWidth: Boolean = true,
    decorFitsSystemWindows: Boolean = true,
    windowTitle: String = "",
    windowType: Int = WindowManager.LayoutParams.TYPE_APPLICATION,
    windowToken: IBinder? = null,
    blurBehindRadius: Dp = Dp.Unspecified,
    backgroundBlurRadius: Dp = Dp.Unspecified,
    scrimAlpha: Float = Float.NaN,
    windowShape: Shape? = null
)

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

Public properties

backgroundBlurRadius

val backgroundBlurRadiusDp

Blurs the screen behind the window within the bounds of the window. The density of the blur is set by the blur radius. The radius defines the size of the neighboring area, from which pixels will be averaged to form the final color for each pixel. The operation approximates a Gaussian blur. A radius of 0.dp means no blur. The higher the radius, the denser the blur. The window background drawable is drawn on top of the blurred region. The blur region bounds and rounded corners will mimic those of the background drawable. Note the difference with blurBehindRadius, which blurs the whole screen behind the window. Background blur blurs the screen behind only within the bounds of the window. For background blur, a radius of 30.dp (~80 px) creates a good frosted-glass effect. Avoid blur radii higher than 50.dp (~150 px), as this will significantly impact performance. Some devices might not support cross-window blur due to GPU limitations. It can also be disabled by the system at runtime (e.g. during battery saving mode). In such situations, no blur will be computed or drawn. Supported on Android 12 (Build.VERSION_CODES.S) and above. If the dialog content uses rounded corners, set windowShape to match it so the background blur clips to the rounded corners of the dialog card instead of the default rectangular window bounds.

blurBehindRadius

val blurBehindRadiusDp

Blurs the screen behind the window. The effect is similar to that of scrimAlpha, but instead of having a scrim applied, the content behind the window will be blurred (or combined with the scrim opacity, if such is specified). The density of the blur is set by the blur radius. The radius defines the size of the neighboring area, from which pixels will be averaged to form the final color for each pixel. The operation approximates a Gaussian blur. A radius of 0.dp means no blur. The higher the radius, the denser the blur. Note the difference with backgroundBlurRadius, which blurs only within the bounds of the window. Blur behind blurs the whole screen behind the window. For blur behind, a radius of 10.dp (~20 px) creates a good depth-of-field effect. Avoid blur radii higher than 50.dp (~150 px), as this will significantly impact performance. Some devices might not support cross-window blur due to GPU limitations. It can also be disabled by the system at runtime (e.g. during battery saving mode). In such situations, no blur will be computed or drawn. Supported on Android 12 (Build.VERSION_CODES.S) and above.

decorFitsSystemWindows

val decorFitsSystemWindowsBoolean

Sets WindowCompat.setDecorFitsSystemWindows value. Set to false to use WindowInsets. If false, the soft input mode will be changed to WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE on Build.VERSION_CODES.R and below and WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING on Build.VERSION_CODES.S and above. Window.isFloating will be false when decorFitsSystemWindows is false.

dismissOnBackPress

val dismissOnBackPressBoolean

whether the popup can be dismissed by pressing the back or escape buttons on Android or the escape key on desktop. If true, pressing the back button will call onDismissRequest.

dismissOnClickOutside

val dismissOnClickOutsideBoolean

whether the dialog can be dismissed by clicking outside the dialog's bounds. If true, clicking outside the dialog will call onDismissRequest.

scrimAlpha

val scrimAlphaFloat

The opacity of the scrim (also known as dimming) applied behind the dialog window. Ranging from 0.0f (no scrim) to 1.0f (completely opaque). By default, this value is Float.NaN, which means the dialog retains the standard system dialog behavior with the default scrim opacity defined by the window theme.

securePolicy

val securePolicySecureFlagPolicy

Policy for setting WindowManager.LayoutParams.FLAG_SECURE on the dialog's window.

usePlatformDefaultWidth

val usePlatformDefaultWidthBoolean

Whether the width of the dialog's content should be limited to the platform default, which is smaller than the screen width. Might be used only as named argument.

windowShape

val windowShapeShape?

The Shape applied to the underlying native dialog window background. This defines the geometric outline of the window frame. When set (e.g., RoundedCornerShape or CircleShape), window-level hardware effects such as backgroundBlurRadius will clip to this shape instead of standard 90-degree rectangular bounds. Use this to align the background blur outline with the rounded shape of your dialog content card. If null (default), the window background uses standard rectangular bounds.

Example usage:

windowTitle

val windowTitleString

Title to be set on the dialog's window.

windowToken

val windowTokenIBinder?

An optional android.os.IBinder to be used as the window token for the dialog window. If null, the dialog will typically derive the token from the context. This parameter is crucial for scenarios where the dialog is shown from a context without a suitable default token, such as a Service running in a separate process from the main application. In such cross-process cases, the token from the main application's window should be provided. The provided token must be a valid android.os.IBinder from an existing window and must have the necessary permissions to add windows of the specified windowType. Providing an invalid, stale, or permission-denied token will typically result in a android.view.WindowManager.BadTokenException when the dialog attempts to show.

windowType

val windowTypeInt

An optional android.view.WindowManager.LayoutParams.type to apply to the dialog's underlying android.view.Window. The default value is android.view.WindowManager.LayoutParams.TYPE_APPLICATION, which is the platform's standard dialog window type. Overriding this allows you to change the layer or behavior of the dialog. For example, setting it to android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY allows the dialog to draw on top of other applications (requires the android.Manifest.permission.SYSTEM_ALERT_WINDOW permission). Note: If you are displaying a dialog from a non-Activity context (such as an android.app.Service) but still want it to be anchored to an existing application window, you should leave this as the default type and instead provide the windowToken of the target application window.