Search code examples
xmlandroid-layoutmaterial-uiandroid-alertdialog

how to set dark theme for Material Dialog android


dialog xml

 <style name="Theme.MyApp.Dialog.Alert" parent="ThemeOverlay.Material3.MaterialAlertDialog">
    <item name="android:textColor">@color/md_theme_light_onBackground</item>
    <item name="android:background">@color/md_theme_light_background</item>
    

the missing attribute is the inner items color how to set it

enter image description here


Solution

  • Define dialog in your styles.xml and do whatever modifications required here.

    <style name="MyDialog" parent="Theme.Material3.Dark.Dialog.Alert"/>
    

    And then in your code

    AlertDialog.Builder(this, R.style.MyDialog)