-
-
Notifications
You must be signed in to change notification settings - Fork 18
Styles
Eltos edited this page Jul 23, 2022
·
11 revisions
The library provides a number of default styles which use the app's primary/secondary color by default and also support dark mode:
@style/SimpleDialogTheme |
@style/SimpleDialogTheme.Material |
@style/SimpleDialogTheme.Material3 |
---|---|---|
You can specify a global theme for dialogs in your apps styles.xml
.
- Use the
alertDialogTheme
attribute to apply the theme to all dialogs - Or the
simpleDialogTheme
attribute to apply the theme only to SimpleDialogs
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<!-- Using a default style -->
<item name="alertDialogTheme">@style/SimpleDialogTheme</item>
<item name="simpleDialogTheme">@style/SimpleDialogTheme.Material</item>
<!-- Or using a custom style -->
<item name="simpleDialogTheme">@style/MyCustomDialogTheme</item>
</style>
</resources>
You can set custom themes on a per-dialog-basis by using the theme(@StyleRes int theme)
method:
SimpleDialog.build()
// ...
.theme(R.style.MyCustomDialogTheme)
.show(this);
You can also define custom styles in styles.xml
, for example:
<resources>
<style name="MyCustomDialogTheme" parent="SimpleDialogTheme">
<item name="android:colorBackground">#282828</item>
<item name="colorPrimary">#a000ff</item>
<item name="colorSecondary">#d50000</item>
<item name="android:textColorPrimary">#33691e</item>
<item name="checkboxStyle">@style/MyCheckBoxStyle</item>
<item name="textInputStyle">@style/MyTextInputStyle</item>
</style>
<style name="MyCheckBoxStyle" parent="@style/Widget.AppCompat.CompoundButton.CheckBox">
<item name="android:textColor">#64b5f6</item>
</style>
<style name="MyTextInputStyle" parent="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
<item name="endIconMode">none</item>
</style>
<!-- When customizing the theme for a SimpleImageDialog you must either
inherit from "ImageDialogTheme" or specify the two attributes as shown below -->
<style name="MyCustomImageDialogThemeA" parent="ImageDialogTheme">
<!-- ... -->
</style>
<style name="MyCustomImageDialogThemeB" parent="MyCustomDialogTheme">
<item name="android:windowMinWidthMinor">@null</item>
<item name="android:windowMinWidthMajor">@null</item>
<!-- ... -->
</style>
</resources>
Javadoc API
Screenshot gallery
Styling dialogs with themes
Fullscreen dialogs
SimpleDialog
CustomViewDialog
CustomListDialog
SimpleCheckDialog
SimpleColorDialog
SimpleColorWheelDialog
SimpleDateDialog
SimpleEMailDialog
SimpleFormDialog
SimpleImageDialog
SimpleInputDialog
SimpleListDialog
SimplePinDialog
SimpleProgressDialog
SimpleTimeDialog