我想更改警报对话框的背景。我已经尝试过以下代码片段:
<style name="Theme.AlertDialog" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:background">@android:color/transparent</item>
<item name="android:textColor">#659F26</item>
<item name="android:windowTitleStyle">@style/Theme.AlertDialog.Title</item>
</style>
<style name="Theme.AlertDialog.Title" parent="@android:style/TextAppearance.DialogWindowTitle">
<item name="android:background">@drawable/cab_background_top_example</item>
</style>
Java 代码:
ContextThemeWrapper ctw = new ContextThemeWrapper( this, R.style.Theme_AlertDialog);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctw);
alertDialogBuilder.setTitle(getResources().getString(R.string.confirmation));
alertDialogBuilder.setMessage(getResources().getString(R.string.msg));
alertDialogBuilder.show();
我的应用程序显示如下对话框:
虽然我希望它看起来像:
请提出建议,我做错了什么。