As the ‘prefer-color-scheme’-CSS query does not work on Android with a Xamarin.Forms WebView, I needed find a workaround to support dark mode for local HTML content. In this post, I’ll show you a Xamarin.Forms only workaround.

Recently I updated my blog reader app to support the dark mode newer iOS and Android version support. While everything went smooth on iOS and the update is already live in the App Store, I had some more work to do on Android. One of the bigger problems: the WebView I use to view posts does not automatically switch to dark mode with Xamarin.Forms.

What’s causing this problem?

On part of the problem is that the WebView does not support the CSS query “prefers-color-scheme“. This works as intended on iOS however and is a problem specific to Android. You can refer to this issue on the Xamarin.Forms repository on Github.

#android #xamarin #css #dark mode #webview #xamarin #xamarin forms

Solution to Use Xamarin.forms WebView using Css Mode Max on android
2.45 GEEK