This one was pretty tricky because I got fooled into thinking that creating an XML file that contains shape attributes is the solution and setting the solid attribute to transparent would make an Android Dialog‘s background transparent.
This was not the case since I assigned the XML file to the background of a LinearLayout. Most of the forums I read gave this suggestion. However, the result is incorrect.
This is because the background of the Dialog is still not transparent. When I assigned the XML file as the background of the LinearLayout, it only put those attributes on the LinearLayout. Since the Dialog background is not transparent, its solid color overlapped the LinearLayout transparent background thus giving the assumption that it never worked.
To make the background of the Dialog transparent, you can do it this way:
This is my sample XML file set as a drawable background for the LinearLayout.
<solid android:color="#90000000" />
<padding android:left="5sp" android:top="5sp" android:right="5sp" android:bottom="5sp" />
<corners android:radius="5dip" />
The solid attribute contains the value #AARRGGBB where A is alpha while RGB are the 3 colors red, green and blue. I set my alpha’s value to 90 so it would not be so transparent. You can change it according to your preference with values between 0 – 99.
Remember, if you set the alpha value to 00, then it will be the same as being invisible.