maui
maui copied to clipboard
Android Platform App Theme does not automatically update when switching themes
Hi @drasticactions.
We use Visual Studio Professional and this is still an issue for android , Could you please guide and confirm if this is also resolved for Visual Studio Professional
I confirm that this is regression after migration to MAUI 8.0.20 from MAUI 8.0.14, theme switching is broken
Could you please provide a bit more detail here? What is the code that you are using? What isn't working any more? Are there other parts that are still working? Could you please provide a reproduction project that shows what was working before and now doesn't?
Does this only happen on Android or also other platforms?
@Chandrakalavaprani @LeDahu22 I've ran a few tests by changing the app theme on the device and changing it via the userapptheme property and both scenarios are working for me
If you have any specifics here that would be very helpful.
@PureWeen
I am using Application.Current.RequestedTheme to get the System theme.
Steps to reproduce
- Run the App in Dark mode
- Kill the app
- Change the System settings to Light Mode
- Open the APP Bug here :- Application.Current.RequestedTheme is still Dark Kill the app again and open now the Application.Current.RequestedTheme gets correct value
My APP was initially in on .net7 framework , I switched to .net8 for this particular issue I am using Visual Studio Professional 17.9.5 Version
@PureWeen
I am using Application.Current.RequestedTheme to get the System theme.
Steps to reproduce
- Run the App in Dark mode
- Kill the app
- Change the System settings to Light Mode
- Open the APP Bug here :- Application.Current.RequestedTheme is still Dark Kill the app again and open now the Application.Current.RequestedTheme gets correct value
My APP was initially in on .net7 framework , I switched to .net8 for this particular issue I am using Visual Studio Professional 17.9.5 Version
what version of MAUI are you on? did you update to 8.0.20? or are you just using the version that was installed with VS?
- Can you give me specifics on what device you are testing with and if possible a recording?
Hi @PureWeen
I managed to reproduced the issue in a sample project i created : Public repo
I'm running on a physical device, using Android 11 (API 29), with VS 17.9.6.
The sample project currently uses MAUI 8.0.14, with .Net 8.0.4 (in order to demonstrate the regression)
Set system theme to dark mode first.
Steps to reproduce : 1 - Start debug 2 - Click on "Navigate to options" button 3 - Click on "Go to third page" button 4 - Go back to MainPage 5 - Use the button to change app theme 6 - Go back to third page 7 - Everything is fine !
Now, stop debug, make sure to clean your solution (or "git clean -fdx"), change both MAUI Nuget version to 8.0.20 in .csproj file and rebuild. Repeat steps 1 to 6 and see the result (all label in white theme don't switch to black, they remain in white.)
I don't know if it's a dependency injection related issue, but what was working with MAUI 8.0.14 is now broken with 8.0.20.
With 8.0.14 :
With 8.0.20 :
Thanks.
@PureWeen
Attaching here with maui workloads version installed on my machine
Testing with Samsung Galaxy A53 5G, Has Android OS Version 14,
@StephaneDelcroix
Since this is an issue , Do you know any alternative solution for it?
note to self: it's quite strange that DynamicResource keep working, and AppTheme does not
I can repro @LeDahu22 issue, not sure the one reported by @Chandrakalavaprani is the same...
a potential fix for @LeDahu22 issue si here: #21879 but I wasn't able to produce a unit test (because reasons)