我用以下代码创建了一个自定义的AlertDialog:
AlertDialog.Builder builder;
AlertDialog alertDialog;
LayoutInflater inflater = (LayoutInflater)ActivityName.this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_layout,(ViewGroup)findViewById(R.id.layout_root));
builder = new AlertDialog.Builder(getParent());
builder.setView(layout);
alertDialog = builder.create();
alertDialog.show();
问题是弹出窗口被默认对话框背景包围,拥有自己的无标题空间(因为未设置标题)。我该如何移除它?我尝试通过
ContextThemeWrapper
放置自定义样式,例如builder = new AlertDialog.Builder(new ContextThemeWrapper(getParent(), R.style.CustomDialogTheme));
,但这并不起作用。我该怎么做?提前感谢您的帮助。
以下是自定义样式xml:<style name="CustomDialogTheme" parent="android:style/Theme.Dialog.Alert">
<item name="android:windowIsFloating">false</item>
<item name="android:windowNoTitle">true</item>
</style>