Issue
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
Solution
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
:
With 0.8
:
Answered By - Gabriele Mariotti
Answer Checked By - Katrina (JavaFixing Volunteer)