In my Compose activity, I have following AlertDialog
:
AlertDialog(
title = { Text(text = dialogTitle) },
text = { Text(text = dialogDescription) },
confirmButton = {}
)
It looks like this:
The problem is, that I would like this AlertDialog
to support light/dark mode. Now, it is always white (light). I have tried to create Modifier
where I changed background, but it does not work. Can somebody help me solve this issue? I did not find any specific guide to AlertDialogs in official documentation. Thank you.
set containerColor
, titleContentColor
,textContentColor
based on your theme
AlertDialog(
onDismissRequest = {},
confirmButton = {},
modifier = Modifier,
dismissButton = { },
icon = {},
title = { Text(text = "Test title") },
text = { Text(text="Test Description") },
containerColor = Color.Black,
iconContentColor = AlertDialogDefaults.iconContentColor,
titleContentColor = Color.White,
textContentColor = Color.White,
tonalElevation = AlertDialogDefaults.TonalElevation,
)
Result will be