Hello, may I ask, the dark theme of Andriod and IOS, the setting does not change with the system, what should I do?
1 Answer, 1 is accepted
0
Yana
Telerik team
answered on 04 Jun 2021, 10:01 AM
Hi Guo,
Starting with R1 2021 our Xamarin controls provide support for dark theme/mode on both Android and iOS. Please go through our documentation topic for detailed information on the matter: Telerik UI for Xamarin: Dark Mode.
In general, for Android in order to enable the dark mode, you just need to add the following line inside Resources/values/styles.xml file located in the Android project:
I received it, but it is not the answer I want. I want the Android system to be set to dark mode, but the app will not change to dark mode. How to implement this switch with C# code, thank you
Alex
Telerik team
commented on 09 Jun 2021, 10:07 AM
Hi Guo,
To set any color for light and dark mode you can use the following syntaxis:
For XAML - {AppThemeBinding Light=Desired light color, Dark=Desired dark color}
For C# - Color myColor = Application.Current.RequestedTheme == OSAppTheme.Dark ? desired dark color : desired light color;
If you want to implement a functionality that switches between light and dark mode you can check our Telerik UI for Xamarin Sample App and more specifically its ChangeAppThemeModeCommand which is used in HomeViewModel class.
For more information about how to respond to system theme changes - check this help article
I hope that the provided information was helpful. Let me know if you have any additional questions or concerns on this.