我想更改Alert對話框的背景。我曾嘗試下面的代碼塊這樣做:如何更改Android Alert對話框的背景標題
<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();
我的應用程序是顯示對話框如下:
,而我希望它看起來如:
請建議,我在做什麼錯。
爲什麼向下票呢? – mudit
我只是從你的問題解決我的問題,所以+1從我身邊..... – duggu