Adrian Adrian - 5 months ago 45
Android Question

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?

Answer

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>
Comments