I want to change the background of alert dialog title in theme. I do following changes in theme:
<style name="NgTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:dialogTheme">@style/NgDialogTheme</item>
<item name="android:alertDialogTheme">@style/NgAlertDialogTheme</item>
</style>
<style name="NgDialogTheme" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:background">@android:color/transparent</item>
<item name="android:windowTitleStyle">@style/NgWindowTitleStyle</item>
</style>
<style name="NgAlertDialogTheme" parent="@style/NgDialogTheme">
</style>
<style name="NgWindowTitleStyle" parent="android:TextAppearance.Holo.DialogWindowTitle">
<item name="android:background">#318d99</item>
<item name="android:textColor">#fff</item>
</style>
I expected that background of title becomes #318d99. But only background of text is #318d99:
There are some valuable posts about this already and very closely related to your question.
Specifically, go to Part 5: Styling the Background .
To summarize, they suggest that you will probably have to
You'll want to create a new style that inherits from the default alertdialog theme (this is discussed in both posts I mentioned above):
<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
<item name="android:bottomBright">@color/white</item>
<item name="android:bottomDark">@color/white</item>
<item name="android:bottomMedium">@color/white</item>
<item name="android:centerBright">@color/white</item>
<item name="android:centerDark">@color/white</item>
<item name="android:centerMedium">@color/white</item>
<item name="android:fullBright">@color/orange</item>
<item name="android:fullDark">@color/orange</item>
<item name="android:topBright">@color/blue</item>
<item name="android:topDark">@color/blue</item>
</style>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.