Add text style for dialogs

This commit is contained in:
Benoit Marty 2021-06-23 15:26:19 +02:00
parent 11b16ea065
commit 9ac0f6d86b
2 changed files with 24 additions and 3 deletions

View file

@ -69,7 +69,7 @@ abstract class DebugMaterialThemeActivity : AppCompatActivity() {
private fun showTestDialog(theme: Int) { private fun showTestDialog(theme: Int) {
MaterialAlertDialogBuilder(this, theme) MaterialAlertDialogBuilder(this, theme)
.setTitle("Dialog title") .setTitle("Dialog title")
.setMessage("Dialog content") .setMessage("Dialog content\nLine 2")
.setIcon(R.drawable.ic_debug_icon) .setIcon(R.drawable.ic_debug_icon)
.setPositiveButton("Positive", null) .setPositiveButton("Positive", null)
.setNegativeButton("Negative", null) .setNegativeButton("Negative", null)

View file

@ -1,7 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="ThemeOverlay.Vector.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog" /> <style name="ThemeOverlay.Vector.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialog.Vector.Title.Text</item>
<item name="materialAlertDialogBodyTextStyle">@style/MaterialAlertDialog.Vector.Body.Text</item>
<item name="buttonBarPositiveButtonStyle">@style/Widget.Vector.Button.TextButton.Dialog</item>
<item name="buttonBarNegativeButtonStyle">@style/Widget.Vector.Button.TextButton.Dialog</item>
<item name="buttonBarNeutralButtonStyle">@style/Widget.Vector.Button.TextButton.Dialog</item>
</style>
<style name="ThemeOverlay.Vector.MaterialAlertDialog.Destructive"> <style name="ThemeOverlay.Vector.MaterialAlertDialog.Destructive">
<item name="buttonBarPositiveButtonStyle">@style/Widget.Vector.Button.TextButton.Dialog.Destructive</item> <item name="buttonBarPositiveButtonStyle">@style/Widget.Vector.Button.TextButton.Dialog.Destructive</item>
@ -11,9 +17,24 @@
<item name="buttonBarNegativeButtonStyle">@style/Widget.Vector.Button.TextButton.Dialog.Destructive</item> <item name="buttonBarNegativeButtonStyle">@style/Widget.Vector.Button.TextButton.Dialog.Destructive</item>
</style> </style>
<style name="Widget.Vector.Button.TextButton.Dialog" parent="Widget.MaterialComponents.Button.TextButton.Dialog" /> <!-- Title -->
<style name="MaterialAlertDialog.Vector.Title.Text" parent="MaterialAlertDialog.MaterialComponents.Title.Text">
<item name="android:textAppearance">@style/TextAppearance.Vector.Subtitle</item>
</style>
<!-- Body -->
<style name="MaterialAlertDialog.Vector.Body.Text" parent="MaterialAlertDialog.MaterialComponents.Body.Text">
<item name="android:textAppearance">@style/TextAppearance.Vector.Body</item>
<item name="lineHeight">20sp</item>
</style>
<!-- Buttons -->
<style name="Widget.Vector.Button.TextButton.Dialog" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textAppearance">@style/TextAppearance.Vector.Button</item>
</style>
<style name="Widget.Vector.Button.TextButton.Dialog.Destructive"> <style name="Widget.Vector.Button.TextButton.Dialog.Destructive">
<item name="materialThemeOverlay">@style/VectorMaterialThemeOverlayDestructive</item> <item name="materialThemeOverlay">@style/VectorMaterialThemeOverlayDestructive</item>
</style> </style>
</resources> </resources>