Dark Theme for Android And Dark Mode for iOS

1 Answer 216 Views
Styling
guo
Top achievements
Rank 1
Iron
guo asked on 04 Jun 2021, 08:59 AM
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

Sort by
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:

<style name="MainTheme" parent="Theme.AppCompat.DayNight">

As to iOS - there's nothing more you need to do, the controls react automatically to system appearance changes.

Let me know if you have any additional questions or concerns on this.

Regards,
Yana
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

guo
Top achievements
Rank 1
Iron
commented on 05 Jun 2021, 12:25 AM

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.

 

Tags
Styling
Asked by
guo
Top achievements
Rank 1
Iron
Answers by
Yana
Telerik team
Share this question
or