[PreferenceFragmentCompat] Dialogs are not shown in Material Design M3 style
See original GitHub issueDescription: Dialogs in [PreferenceFragmentCompat] are not shown in Material Design M3 style. Instead, for example, wrong colors and dialog outlines are used as shown below. The issue is especially visible when using the DynamicColors feature.
Expected behavior: I expected that [PreferenceFragmentCompat] shows dialogs in Material Design M3 style, i.e. about as shown below (I’ve tried to rebuild the expected M3 design by using a ThemeOverlay, but didn’t manage e.g. to get the correct backgrounc color).
Source code: Here are some code snippets…
PreferenceFragmentCompat
public class SettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
private Context mContext;
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
// Load the preferences from an XML resource
setPreferencesFromResource(R.xml.settings, rootKey);
}
themes.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme -->
<style name="AppTheme" parent="AppTheme.Base" />
<style name="AppTheme.Base" parent="Theme.Material3.Light">
Android API version: 32 & 33 (Tiramisu)
Material Library version: com.google.android.material:material:1.7.0-alpha02
Device: Pixel 5 Emulator
Issue Analytics
- State:
- Created a year ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Adjust androidx.preference dialogs to follow Material You
Now, i themed my app to use and follow the new Material3 (or Material You) theme, but a problem i'm facing is that...
Read more >Dialogs – Material Design 3
Dialogs provide important prompts in a user flow. ... Dialogs should appear in response to a user task or an action, with relevant...
Read more >Releases · material-components/material-components-android
Modular and customizable Material Design UI components for Android - Releases ... is hidden (ed11e69); Updated tooltip shape style to use M3 shape...
Read more >androidx.compose.material3 - Android Developers
The Material Design type scale includes a range of contrasting styles that ... the given style with the current style values for any...
Read more >Everything you need to know about Material Design 3
UI Components got a style refresh too. Generally speaking, Material Design 3 adopts a simpler, more playful look. It features rounder elements, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh gotcha. So with MaterialAlertDialogBuilder the surface color is calculated on-the-fly (for now) - a small percentage of
?attr/colorPrimary
is overlaid upon the pure?attr/colorSurface
. We have no control over the framework alert dialog, so the color you see will be pure?attr/colorSurface
.To achieve the same color, the easiest way might be setting the color programmatically after the dialog is created - by using SurfaceColors.SURFACE_3.getColor().
Another approach is overriding
?android:attr/windowBackground
and manually overlaying the color with layer-list. Here’s an example to refer to: https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/menu/res/drawable-v23/m3_popupmenu_background_overlay.xmlCould any one give me a full code on this. I also have a list-preference which I need to support m3