Search code examples
androidandroid-alertdialogandroid-appcompatandroid-theme

alertDialogTheme not working (AppCompat v23)


I am having a theme in the following way:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="alertDialogTheme">@style/AppTheme.Dialog</item>
</style>

<style name="AppTheme.Dialog" parent="Theme.AppCompat.Dialog.Alert">
    <item name="colorAccent">@color/accent</item>
</style>

However, when I create AlertDialogs inside my app, they are not themed at all. Other components like the ActionBar are being colored properly. Am I missing something?

I am using the AppCompat version com.android.support:appcompat-v7:23.1.1 and my device has Android 4.4.4 installed.


Solution

  • For anyone stumbling upon this question with similar problems: Please double-check that you are using the AlertDialog.Builder from the support library package, so the import statement should look like:

    import android.support.v7.app.AlertDialog;
    

    In my case I was importing android.app.AlertDialog which led to the wrong results.