I am trying to migrate from default android AlertDialog
to the new one included in appCompat-22.1
So far I understand you only have to import android.support.v7.app.AlertDialog
package in order to use it.
But how can I style it? For example change the positive/negative button colors, title color, message color and background color?
To use a theme for all the application, and don't use the second parameter to style your Dialog
On my app using a color accent in theme don't show the alertDialog's buttons with the theme colorAccent I have to add a dialog style in the theme.
When creating the
AlertDialog
you can set a theme to use.Example - Creating the Dialog
styles.xml - Custom style
Result
Edit
In order to change the Appearance of the Title, you can do the following. First add a new style:
afterwards simply reference this style in your
MyAlertDialogStyle
:This way you can define a different
textColor
for the message viaandroid:textColorPrimary
and a different for the title via the style.If you want to use the new android.support.v7.app.AlertDialog and have different colors for the buttons and also have a custom layout then have a look at my https://gist.github.com/JoachimR/6bfbc175d5c8116d411e
Follow @reVerse answer but in my case, I already had some property in my
AppTheme
likeSo my dialog will look like
![enter image description here](https://i.stack.imgur.com/GjNea.png)
I solved it by
1) Change the import from
android.app.AlertDialog
toandroid.support.v7.app.AlertDialog
2) I override 2 property in
AppTheme
with null value.
Hope it help another people