Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force light mode in Xamarin.Forms?

My app's UI is designed to use in light mode. But if the phone's default theme is dark mode, my app also switches to dark mode and the UI looks trash. So I want force my app to use light mode. How can I do this?

In my app.xaml file I used UserAppTheme="Light", set Content page's background color to variant white color (ex. #FFF, #F2F3F4) but still it doesn't works. I even tried applying <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar"> in styles.xml. But if the phone is in the dark mode, all the white like area becomes dark too.

I tested in MIUI 12.

like image 860
Mahmudul Hasan Avatar asked Dec 08 '22 10:12

Mahmudul Hasan


1 Answers

iOS update your info.plist:

<key>UIUserInterfaceStyle</key>
<string>Light</string>

Android change the style of MainTheme.Base to DayNight:

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

Original answer & more detail from James Montemagno blog

like image 79
Visual Sharp Avatar answered Dec 28 '22 06:12

Visual Sharp