3

I'm trying to style an AlertDialog. It works fine on API 23 and 24, but on 19 it doesn't. Here is what it should look like:

Correct

And what it looks like on API 19:

Incorrect

I can't find any information on what items I have to edit to change those black colors, or remove that light blue line, or that extra shadow that shouldn't be there, or even a list of the style items that apply to an AlertDialog. Here is what my style looks like. I added a bunch of items that I probably don't need as I was trying to fix this.

    <style name="AlertDialogTheme" parent="Base.Theme.AppCompat.Dialog.Alert">
    <item name="colorPrimary">#ffffffff</item>
    <item name="colorPrimaryDark">#ffffffff</item>
    <item name="colorAccent">#ffffffff</item>
    <item name="android:actionModeBackground">@color/dialogBackground</item>
    <item name="android:textColor">#ffffffff</item>
    <item name="android:textColorPrimary">#ffffffff</item>
    <item name="android:background">#ff005e9e</item>
    <item name="actionModeBackground">@color/dialogBackground</item>
    <item name="actionButtonStyle">@color/dialogBackground</item>
    <item name="actionBarItemBackground">@color/dialogBackground</item>
    <item name="background">@color/dialogBackground</item>
    <item name="android:colorBackground">@color/dialogBackground</item>
    <item name="android:colorBackgroundCacheHint">@color/dialogBackground</item>
    <item name="colorBackgroundFloating">@color/dialogBackground</item>
    <item name="colorControlNormal">#ff005e9e</item>
    <item name="colorControlActivated">#ff005e9e</item>
    <item name="colorControlHighlight">#30FFFFFF</item>
    <item name="android:windowBackground">@color/dialogBackground</item>
    <item name="android:shadowColor">@color/dialogBackground</item>
</style>

I need some help figuring out what setting I have to change here.

Thanks in advance.

Jorge Bonafé
  • 193
  • 1
  • 11
  • i tried your style on api 19 and it worked fine. which folder is the themes.xml in. And is there any code doing anything? – Matthew Shearer Apr 27 '17 at 06:22
  • Which `AlertDialog` class are you using? `android.app.AlertDialog` or `android.support.v7.app.AlertDialog`? – Mike M. Apr 27 '17 at 06:28
  • I was using android.app.AlertDialog. I tried changing it to android.support.v7.app.AlertDialog and the whole screen changed to white, the button texts are not visible anymore – Jorge Bonafé Apr 27 '17 at 06:38
  • Here is the project if it helps. The activity is CompilerActivity, the dialog is on confirmClose() for example: https://gitlab.com/jorgebonafe/LEGALB – Jorge Bonafé Apr 27 '17 at 06:39
  • 1
    Actually, now that I changed it to android.support.v7.app.AlertDialog and changed a few of the colors around it worked, so that was the problem. Thanks Mike – Jorge Bonafé Apr 27 '17 at 06:45
  • Don't set `android:background` in a *theme*. It gets applied to every widget that would otherwise be transparent (or more precisely did not specify its own background). This causes severe overdraw and performance penalty. It may also cause unwanted behavior for ripples. – Eugen Pechanec Apr 27 '17 at 08:31

1 Answers1

2

So the problem was that I was using android.app.AlertDialog when i should be using android.support.v7.app.AlertDialog. I changed it and now it's working as intended.

Jorge Bonafé
  • 193
  • 1
  • 11