Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change the Color Behind Android Dialog

I would like to change the color of the dimmed background that surrounds an Android dialog (not the Window background drawable) programmatically. I am using a dialog themed activity. I do not want to dim it, nor blur it.

If you imagine a dialog with three buttons, I would like to have it do something like this:

  • Click A: background to translucent red
  • Click B: background to translucent yellow
  • Click C: background to translucent green
like image 969
Jason Van Anden Avatar asked Sep 12 '11 16:09

Jason Van Anden


1 Answers

I'm not sure you can change the color of the background. The dimming is controlled by the dimAmount field of the layout for the dialog window (as well as the FLAG_DIM_BEHIND flag). dimAmount is just a float between 0.0 and 1.0 that controls the amount of dimming (transparent to totally opaque). I think it's just an alpha blend of the existing background; there's no control of coloring as far as I've been able to find.

like image 186
Ted Hopp Avatar answered Oct 18 '22 07:10

Ted Hopp