We are switching to Material 3 and I’m trying to create a MaterialAlertDialog with a stroke (border). I’ve tried a lot of different things and read a lot of different articles, but I don’t get the desired result.
What we want to achieve:
https://i.sstatic.net/Z5BU6GmS.png
The best result so far is:
https://i.sstatic.net/OlOoLz01.png
I don’t know why the “android:background” is applied to every component separately.
Here is the theme and the styles we are using:
<style name="App_Theme" parent="Theme.Material3.Dark.NoActionBar">
<item name="materialAlertDialogTheme">@style/AlertDialog</item>
</style>
<style name="AlertDialog" parent="ThemeOverlay.Material3.MaterialAlertDialog">
<item name="android:background">@drawable/shape_dialog_background</item>
</style>
shape_dialog_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="@color/colorDialogBackground" />
<corners android:radius="28dp" />
<stroke
android:width="4dp"
android:color="@color/colorDialogStroke" />
</shape>
And the dialog itself is created like this:
new MaterialAlertDialogBuilder(ServerDetailsForm.this)
.setTitle(R.string.dlg_unsaved_changes_title)
.setMessage(R.string.dlg_unsaved_changes_description)
.setPositiveButton(R.string.filters_dialog_cancel, dialogClickListener)
.setNegativeButton(R.string.dlg_btn_unsaved_changes_discard, dialogClickListener)
.show();
What am I missing here?
Let me know if any additional information is needed. Thanks!