Skip to content
Philipp Niedermayer edited this page Oct 25, 2020 · 11 revisions

Provided default styles

The library provides a number of default styles.

@style/SimpleDialogTheme @style/SimpleDialogMaterialTheme

Applying styles

Globally

You can specify a global theme with the alertDialogTheme attribute (all dialogs) or the simpleDialogTheme attribute (only simple dialogs) in your apps styles.xml. Here is a simple example, have a look at styles.xml for a more advanced example:

<resources>
<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
        <!-- use the provided default styles-->
        <item name="alertDialogTheme">@style/SimpleDialogTheme</item>
        <item name="alertDialogTheme">@style/SimpleDialogMaterialTheme</item>

        <!-- specify a custom style-->
        <item name="simpleDialogTheme">@style/MyDialogTheme</item>
    </style>
    <style name="MyDialogTheme" parent="SimpleDialogTheme">
        <!-- customizations for all dialogs -->
        <item name="colorPrimary">@color/colorAccent</item>
    </style>
</resources>

Per dialog

You can set custom themes on a per-dialog-basis by using the theme(int resId) method. See SimpleDialog.