When we customize dialog, we tend to want to remove the Android system definition background and title, so that we can better display our own desired effect.
In fact, we just need to pay attention to a few places on the line.
1. Define the theme of dialog in the style file
- <style name="Mydialog">
- <item name="Android:windowframe"> @null</Item>
- <item name="Android:windowbackground"> @android: color/transparent</ Item>
- <item name="Android:windownotitle">true</Item>
- <item name="android:windowisfloating">true</Item>
- <item name="Android:windowcontentoverlay"> @null</Item>
- </style>
The main thing is this: <item name= "Android:windowbackground" > @android:color/transparent</item> set Windowbackground to Transparent
2. Used in the custom dialog construction method, if you use this theme in the dialog layout file is not useful, you must use this theme in all three construction methods, so that you do not have to invoke the theme when you enter which constructor method. Otherwise you will not see the effect.
Public Mydialog (Context context) {
Super (Context,r.stytle.mydialog);
}
Public Mydialog (Context context,int thremid) {
Super (Context,r.stytle.mydialog);
}
So your dialog should be able to show no black background and no border.
Remove Android Custom dialog black background, set no border, transparent