This sample shows how to enable Material 3 for a .NET MAUI Android app and customize colors at both layers:
- Android's native Material 3 theme through
Platforms/Android/Resources/values/colors.xml. - MAUI/XAML styling through
Resources/Styles/Colors.xaml.
MauiMaterial3CustomizationSample.csprojenables Material 3 with<UseMaterial3>true</UseMaterial3>and pins the MAUI package to10.0.60.Platforms/Android/Resources/values/colors.xmloverrides both the legacy Android aliases and the Material 3m3_sys_color_*roles used by the native Android Material 3 theme.Resources/Styles/Colors.xamldefines the same teal Material 3-inspired palette for cross-platform MAUI resources.MainPage.xamlincludes aColors.xamlcard with explicit XAML bindings, followed by native MAUI controls that get their Android styling fromcolors.xml.App.xamlintentionally only mergesResources/Styles/Colors.xamlso global implicit XAML styles do not hide the native Material 3 colors.
Install the .NET 10 SDK with the MAUI workload, then run:
dotnet restore
dotnet build -t:Run -f net10.0-androidFor real Android Material 3 theme changes, update the m3_sys_color_light_* and m3_sys_color_dark_* values in colors.xml, not only colorPrimary.
For app-level MAUI styling, update Resources/Styles/Colors.xaml and bind those resources from XAML with StaticResource or AppThemeBinding.
Only if you are styling your own MAUI/XAML UI. Colors.xaml defines resources, but it does not automatically change Android's native Material 3 theme.
This repo includes two experiment screenshots:
screenshots/before-default-material3.png: Material 3 is enabled with the default purple Android theme and default purpleColors.xamlresources.screenshots/experiment-colors-xaml-only.png: Androidcolors.xmlwas reset to the default purple values whileColors.xamlwas changed to an intentionally orange palette. The explicitly bound XAML card is orange, but the native Material 3 controls still use the Android theme colors.screenshots/experiment-colors-xaml-with-styles.png:Styles.xamlwas also merged, so some MAUI control properties picked up teal XAML resources. Native theme-owned pieces still come from Android resources.
Recommended rule: put the same palette in both places. Use colors.xml for Android's native Material 3 theme and Colors.xaml for MAUI/XAML UI that you style yourself.
