如果您希望对话框全屏显示,则使用 AlertDialog.THEME_HOLO_LIGHT 即可。另一种方法是创建自己的样式,如下所示:
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.ThemeDialogCustom);
ListAdapter adapter = new CustomDialogAdapter(context, itemsList);
builder.setAdapter(adapter, listener);
builder.setTitle(title);
AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(true);
在 values 文件夹中有 style.xml,如下所示:::
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ThemeDialogCustom" parent="android:Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowBackground">@color/transparent_color</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:colorBackgroundCacheHint">@null</item>
</style>
</resources>
还在 values 文件夹中添加 colors.xml:::
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="transparent_color">#00000000</color>
</resources>
这对我有用。希望它也对你有用