Jetpack Compose - Can't change AlertDialog white window background

Viewed 22

I'm new to Kotlin Multiplatform Desktop development and I'm using Compose to build UI. I have one AlertDialog with custom, rounded background, problem is, it still has white corners which I can not remove for some reasons. The dialog:

The code I've written to achieve this:

 AlertDialog(
        title = { Text("თქვენ ტოვებთ პროგრამას") },
        text = { Text("ნამდვილად გსურთ პროგრამიდან გასვლა?") },
        onDismissRequest = {},
        backgroundColor = Colors.DARKER_GRAY,
        contentColor = Colors.WHITE,
        shape = RoundedCornerShape(16.dp),
        confirmButton = {
            TextButton(onClick = onPositiveClick) {
                Text(text = "დიახ", color = Colors.RED)
            }
        },
        dismissButton = {
            TextButton(onClick = onNegativeClick) {
                Text(text = "არა", color = Colors.LIGHTER_GRAY)
            }
        },
        modifier = Modifier.defaultMinSize(300.dp).border(0.dp, Color.Transparent, RoundedCornerShape(0))
    )

Anyone has any idea how can I solve this? Thank You in advance.

1 Answers

If I may ask you, is that the preview because if I wrap your code in a column and change its background colour and runs it, it works perfectly okay.

Dialog in column

    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.Red),
        verticalArrangement = Arrangement.SpaceEvenly,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
///Your code is here
        AlertDialog(
            title = { Text("თქვენ ტოვებთ პროგრამას") },
            text = { Text("ნამდვილად გსურთ პროგრამიდან გასვლა?") },
            onDismissRequest = {},
            backgroundColor = Color.Gray,
            contentColor = Color.White,
            shape = RoundedCornerShape(16.dp),
            confirmButton = {
                TextButton(onClick = { /*onPositiveClick*/ }) {
                    Text(text = "დიახ", color = Color.Red)
                }
            },
            dismissButton = {
                TextButton(onClick = { /*onNegativeClick*/ }) {
                    Text(text = "არა", color = Color.LightGray)
                }
            },
            modifier = Modifier
                .defaultMinSize(300.dp)
                .border(0.dp, Color.Transparent, RoundedCornerShape(0))
        )
    }
Related