DialogProperties
-
Cmn
class DialogProperties
Properties used to customize the behavior of a Dialog.
Summary
Public constructors |
|
|---|---|
DialogProperties( |
Cmn
android
|
DialogProperties( |
android
|
Public properties |
||
|---|---|---|
Boolean |
Sets |
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
|
SecureFlagPolicy |
Policy for setting |
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
|
String |
Title to be set on the dialog's window. |
android
|
IBinder? |
An optional |
android
|
Int |
An optional |
android
|
Public constructors
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
)
Public properties
decorFitsSystemWindows
val decorFitsSystemWindows: Boolean
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 dismissOnBackPress: Boolean
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 dismissOnClickOutside: Boolean
whether the dialog can be dismissed by clicking outside the dialog's bounds. If true, clicking outside the dialog will call onDismissRequest.
securePolicy
val securePolicy: SecureFlagPolicy
Policy for setting WindowManager.LayoutParams.FLAG_SECURE on the dialog's window.
usePlatformDefaultWidth
val usePlatformDefaultWidth: Boolean
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.
windowToken
val windowToken: IBinder?
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.
Example usage:
windowType
val windowType: Int
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.