The prompts displayed by DisplayAlert do not follow the theme set
Description
The prompts displayed by DisplayAlert do not adhere to the theme set by using Application.Current.UserAppTheme.

Steps to Reproduce
- Set the theme to dark using
Application.Current.UserAppTheme = AppTheme.Dark; - Send a DisplayAlert on the main page on Android. The theme will not be respected and it will use the default light theme.
Version with bug
Release Candidate 1 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
API 30, Android 11
Did you find any workaround?
No response
Relevant log output
No response
@emorell96 Thank you so much for your bug report! Unfortunately, we cannot reproduce your issue with the information above, could you provide a sample project/screenshots or more details that we can reproduce your issue? That should greatly speed up the process, thanks!
Hi @emorell96. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
Hi, I'm not sure I understand why #7601 was closed as a duplicate of this issue... it is a completely separate issue that I am experiencing as well. On an Android device set to dark mode, DisplayAlert is presented with a dark gray background and dark (purple?) text that is barely readable. Has a workaround been identified for that issue? Thanks
THIS IS A BIG PROBLEM.
Application.Current.UserAppTheme only applys for the theme defined with AppThemeBinding as mentioned in this post. That means DisplayAlert, Picker, etc. don't inherit the specified theme. To fix this problem, make sure to run this code when switching themes:
#if ANDROID
AndroidX.AppCompat.App.AppCompatDelegate.DefaultNightMode = Current.UserAppTheme switch
{
AppTheme.Light => AndroidX.AppCompat.App.AppCompatDelegate.ModeNightNo,
AppTheme.Dark => AndroidX.AppCompat.App.AppCompatDelegate.ModeNightYes,
_ => AndroidX.AppCompat.App.AppCompatDelegate.ModeNightFollowSystem
};
#elif IOS
Platform.GetCurrentUIViewController().OverrideUserInterfaceStyle = Current.UserAppTheme switch
{
AppTheme.Light => UIKit.UIUserInterfaceStyle.Light,
AppTheme.Dark => UIKit.UIUserInterfaceStyle.Dark,
_ => UIKit.UIUserInterfaceStyle.Unspecified
};
#endif
I haven't tested on iOS but it should work.
Much appreciated. You rock, sir.
So is there any solution for this? Since the one above is for xamarin forms?
Okay, so just go:
$"[YourProject]"/Platforms/Android/Resources/values/colors. Change it there. That is it.
The solution I mentioned is for both xamarin and MAUI. It works fine for me. From my knowledge, changing the values in Platforms/Android/Resources/values/colors.xml only changes the default button color in the dialog and in a few other areas. It doesn't change the dialog color.
I created a plugin that handles some workarounds (maui). If you want, you can check it out here.