我想在我的Android应用程序中自定义警报对话框,因此我首先更改了我的应用程序主题的alertDialogTheme属性,如下所示:
res/values/themes.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:alertDialogTheme">@style/AlertDialogTheme</item>
</style>
<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert"/>
</resources>
仅仅通过这样做,我并没有期望对话框会与标准的外观有所不同,因为新的主题AlertDialogTheme与其父主题完全相同。在Android Lollipop上它可以正常工作,但是在Android Kitkat上对话框后面会出现一个白色矩形。以下是它的外观:
我做错了什么吗?也许使用了错误的父元素?
谢谢!