Alex Sullivan
Alex Sullivan

Reputation: 572

Overriding android material design alert dialogs

I'm attempting to change the color of the "cancel" button on the android L alert dialogs by setting the alertDialogTheme attribute of my theme as follows:

<item name="android:alertDialogTheme">@style/AlertDialogStyle</item>

Right now the AlertDialogStyle is empty:

<style name="AlertDialogStyle" parent="android:style/Theme.Material.Light.Dialog">

</style>

I know I can use the

android:buttonBarNegativeButtonStyle

property to update the color/style of those buttons. The issue I'm having is that by descending from the Theme.Material.Light.Dialog style, all of my dialogs are having their width reduced to (what appears to be) wrap_content. I have a few custom alert dialogs, and that width looks atrocious. Has anyone run into this problem and if so has anyone fixed it?

EDIT: I've also tried setting the parent to

android:Theme.Material.Light.Dialog

with no luck.

Upvotes: 1

Views: 1233

Answers (1)

Alex Sullivan
Alex Sullivan

Reputation: 572

The solution was to descend from

android:Theme.Material.Light.Dialog.Alert

That fixed everything right up.

Upvotes: 1

Related Questions