How to change the width of dialog in android compose


It seems impossible to change the width of the dialog with Compose. The closest I’ve come to with changing the dialog width is through DialogProperties.usePlatformDefaultWidth. Setting it to false causes the dialog to fill the screen but is there a way to use custom width?


Use can define a custom AlertDialog using the constructor with text,title and buttons parameters and applying a size (for example with the Modifier.size) and overriding the default behaviour with usePlatformDefaultWidth false :

    onDismissRequest  { /*TODO*/ },
    title  {
        Text(text  "Title")
    text  {
            "This area typically contains the supportive text " +
                    "which presents the details regarding the Dialog's purpose."
    buttons  {},
    properties  DialogProperties(
        usePlatformDefaultWidth  false
    modifier  Modifier.size(200.dp,250.dp)

enter image description here

Answered By – Gabriele Mariotti

Leave a Comment