Steve Haley Steve Haley - 1 year ago 118
Android Question

Button style in AlertDialogs

Does anyone know how to override the default style for AlertDialog buttons? I've looked through the Android source for themes and styles and experimented with different things but I haven't been able to find a way that works.

What I've got below works for changing the backgrounds, but doesn't do anything with the buttons.

is applied to the whole
via the manifest. (Some other items were deleted for clarity, but they only relate to the title bar.)

<style name="myTheme" parent="android:Theme">
<item name="android:buttonStyle">@style/customButtonStyle</item>
<item name="android:alertDialogStyle">@style/dialogAlertTheme</item>

<style name="dialogAlertTheme" parent="@android:style/Theme.Dialog.Alert">
<item name="android:fullDark">@drawable/dialog_loading_background</item>
<item name="android:topDark">@drawable/dialog_alert_top</item>
<item name="android:centerDark">@drawable/dialog_alert_center</item>
<item name="android:bottomDark">@drawable/dialog_alert_bottom</item>
<!-- this last line makes no difference to the buttons -->
<item name="android:buttonStyle">@style/customButtonStyle</item>

Any ideas?

Answer Source

I guess you have to implement your own Dialog class.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download