0

I am building a dialog with DialogFragment, and I need to change the color of the shadow (mask), which is transparent and always around the main dialog content. Actually, almost all of the answers on the web is to change the dialog box color, but I need to change the shadow color from transparent black to others. Is there any way to do that?

image:

enter image description here

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Karass
  • 21
  • 2

1 Answers1

0

If you only want to change the alpha for the background then you can easily create a style with android:backgroundDimAmount attribute, like I did

<style name="CustomAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:backgroundDimAmount">0.5</item>
</style>

the value ranges 0-1 and then passing the style in your AlertDialog as

AlertDialog dialog = new AlertDialog.Builder(this, R.style.CustomAlertDialogStyle)
            .setTitle("Title").setMessage("message").create();
dialog.show();

But if you want to change the background color as well then you can try this work around given by @Lee Han Kyeol https://stackoverflow.com/a/29482234/5002610 I hope this will solve your issue.

aastha gupta
  • 121
  • 1
  • 11
  • We can change the dimAmount, but we are not able to change the mask color, such like change from black to blue – Karass Aug 22 '18 at 01:31
  • Yes that's right and if you want to have a different color then please go through the link I have in my answer, its not the exact solution but a workaround that can give you the same effect. – aastha gupta Aug 22 '18 at 05:48