Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Alert Dialog with extra background

I recently migrated my app to Material Design and I stumbled upon this problem with my Alert Dialogs:

dialog appears to be having two backgrounds and I don't know how to get rid of the outer background

I'm applying the dialog style like this:

<item name="android:alertDialogTheme">@style/Theme.AlertDialog</item>

and Theme.AlertDialog looks like this:

<style name="Theme.AlertDialog" parent="Base.V14.Theme.AppCompat.Dialog">
    <item name="colorPrimary">@color/theme_primary</item>
    <item name="colorPrimaryDark">@color/theme_primary_dark</item>
    <item name="colorAccent">@color/theme_accent_dark</item>
</style>

This is happening on my Kitkat device and it works fine on Lollipop. Can you help me with getting rid of that outer background?

like image 707
Adrian Avatar asked Apr 02 '15 07:04

Adrian


2 Answers

The point is here:

<style name="Theme.AlertDialog" parent="Base.V14.Theme.AppCompat.Dialog">
    ...
    <item name="colorPrimary">@color/theme_primary</item>
    <item name="colorPrimaryDark">@color/theme_primary_dark</item>
    <item name="colorAccent">@color/theme_accent_dark</item>
    ...
    <item name="android:windowBackground">@android:color/transparent</item>
    ...
</style>
like image 129
SilentKnight Avatar answered Nov 18 '22 07:11

SilentKnight


As ironman told me here, be sure that you import the right class.

Right : import android.support.v7.app.AlertDialog;

Wrong : import android.app.AlertDialog;

like image 37
adiel Avatar answered Nov 18 '22 08:11

adiel