我想制作一个白色的、无边框的弹出视图。为此,我使用具有自定义样式的自定义对话框:
public Builder createNewDialog(int type) {
AlertDialog.Builder dlg = null;
switch (type) {
case (1):
dlg = new AlertDialog.Builder(new ContextThemeWrapper(this,
R.style.CustomDialogTheme));
LayoutInflater inflater = this.getLayoutInflater();
dlg.setView(inflater.inflate(R.layout.dialognewplayer, null))
.setPositiveButton("Add Player", null).setNegativeButton("Cancel", null).create();
break;
}
return dlg;
}
//styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Light"></style>
<style name="CustomDialogTheme" parent="android:Theme.Dialog">
<item name="android:windowBackground">@color/transparent_color</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:background">#ffffff</item>
</style>
</resources>
//和colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="transparent_color">#ffffff</color>
</resources>
但是,正如您在图像中看到的那样,弹出窗口有一些错误......它似乎是双层的,第一层仍然有边框,透明背景仍然是黑色..我想我处理错了,但是我没看到...