在我的应用程序中,我使用AlertDialog类。默认情况下,这些警报对话框具有透明背景。我试图改为使用不透明背景,但一直没有成功。这是我的样式:
<style name="MyOpaqueActivity" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@drawable/my_background</item>
<item name="android:alertDialogStyle">@style/MyOpaqueAlertDialog</item>
</style>
<style name="MyOpaqueAlertDialog" parent="@android:style/Theme.Dialog.Alert">
<item name="android:background">#454545</item>
<item name="android:windowBackground">@drawable/my_background</item>
<item name="android:popupBackground">@drawable/my_background</item>
</style>
我已经成功地为所有活动应用了“MyOpaqueActivity”样式(窗口背景色更改为“my_background”),但在这些活动中的警报对话框中,它不起作用。 "alertDialogStyle" 属性和我的 "MyOpaqueAlertDialog" 样式似乎没有任何效果。
那么,我该如何更改这些警报对话框的背景?