I updated the visual studio, and now I have the same theme of the program as on the phone, it is dark on the phone, and I want the program to be light, please help,I tried Application.Current.UserAppTheme = OSAppTheme.Light,but it does not work
I tried Application.Current.UserAppTheme = OSAppTheme.Light,but it does not work
To respond to theme changes on Android you must include the ConfigChanges.UiMode flag in the Activity attribute of your MainActivity class. Try to add the code in activity class and test again.
No, sorry, I do not know how to do it, I just want that regardless of the theme on the phone my projects had a light theme. Old projects did so, I updated yesterday's visual studio and now everything depends on the system theme on the phone, I want to stop it
@kingston5555 said:
No, sorry, I do not know how to do it, I just want that regardless of the theme on the phone my projects had a light theme. Old projects did so, I updated yesterday's visual studio and now everything depends on the system theme on the phone, I want to stop it
The light theme for the application requests us to customize the settings. When changing the theme of the phone, the application will not change the theme automatically. To keep the light theme for you application, you just need to set a theme style for your application.
To set theme for the application:
try to use AppThemeBinding to set data binding to add styles for the properties.
Answers
To respond to theme changes on Android you must include the
ConfigChanges.UiMode
flag in the Activity attribute of your MainActivity class. Try to add the code in activity class and test again.Check the tutorial:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/theming/system-theme-changes#react-to-theme-changes
I have it.But it does not work
Did you define and the consume theme resources in the application?
Check the tutorial:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/theming/system-theme-changes
No, sorry, I do not know how to do it, I just want that regardless of the theme on the phone my projects had a light theme. Old projects did so, I updated yesterday's visual studio and now everything depends on the system theme on the phone, I want to stop it
The light theme for the application requests us to customize the settings. When changing the theme of the phone, the application will not change the theme automatically. To keep the light theme for you application, you just need to set a theme style for your application.
To set theme for the application:
try to use AppThemeBinding to set data binding to add styles for the properties.
To use the AppTheme class, we need to add the flag before the
Forms.Init
method in the MainActivity class.Check the tutorial:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/theming/theming
Sample code you could refer to:
https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/userinterface-theming/
Add the line in MainActivity ->OnCreate
AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;
(docs.microsoft.com/en-us/answers/questions/231994/disable-dark-mode-in-xamarinforms-48.html)
few hours of my life burned