0

I want to change default AlertDialog theme.

None of the examples I found worked. Here is what I'm doing:

<style name="LightTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="alertDialogTheme">@style/MyCustomDialog</item>
</style>

<style name="MyCustomDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:background">#000000</item>
    <item name="android:textColor">#FFFFFF</item>
</style>

Am I doing something wrong?

4
  • Add you layout (xml) or class code where you are using this theme.
    – Boken
    Commented Mar 26, 2019 at 21:38
  • Shouldn't this change the theme for whole project? I'm using new AlertDialog.Builder(context) Commented Mar 26, 2019 at 21:41
  • Is your LightTheme main app theme (which you are using e.g. in Manifest)?
    – Boken
    Commented Mar 26, 2019 at 21:42
  • Yes, it is. android:theme="@style/LightTheme" Commented Mar 26, 2019 at 21:44

1 Answer 1

0

Ok. I have a solution.

You have to replace android.app.AlertDialog by android.support.v7.app.AlertDialog and in your custom theme you must set <item name="colorAccent">@color/colorAccent</item>

Not the answer you're looking for? Browse other questions tagged or ask your own question.