1

I need to remove the grey background outside the dialog, exactly as shown here: How to remove transparent dark background outside of dialog box Sadly, I'm working with Material Dialog, and it seems I can't call dialog.getWindow().setDimAmount(float amount);

Suggestions? Ty

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
akLab
  • 13
  • 4

1 Answers1

0

You can use the android:backgroundDimAmount attribute (range: 1.0 - 0.0):

<style name="ThemeOverlay.App.MaterialAlertDialog" parent="ThemeOverlay.Material3.MaterialAlertDialog">
    <item name="android:backgroundDimAmount">0.3</item>
</style>

or if you are using a MaterialComponents theme

<style name="ThemeOverlay.App.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
    <item name="android:backgroundDimAmount">0.xx</item>
</style>

and then just call:

MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_App_MaterialAlertDialog)
    //....
    .show()

With 0.2:

enter image description here

With 0.8:

enter image description here

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841