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

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

Since the CSS query 'prefer-color-Scheme' doesn't work on Android with Xamarin.Forms WebView, I needed to find a solution to support dark mode for local HTML content. In this post, I will show you a solution just for Xamarin.Forms.

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

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Building Dark Mode Theme in Android

Hello World, today we are going to see how we can implement a dark theme or night mode in our android application. This tutorial is going to be very simple and easy to understand. The dark theme is attractive to users and it is comfortable for low light conditions.

Xamarin Forms Training Institute | Xamarin Forms Development Classes | Xamarin Training

Xamarin Training course is primarily designed for Beginner(s)/Professional(s) who want to learn how to develop native cross-platform apps with C# that run-on Android, iOS and Windows.

Top Android Projects with Source Code

Android projects with source code - Work on real-time android projects. We’ll start project ideas from beginners level and later move to advance projects.

Dark Mode using CSS Variables

A complete guide for elegantly implementing and switching between light and dark theme for web apps. Dark Mode Switcher Using CSS Variables in LESS, SASS, or Vanilla CSS. Dark Mode using CSS Variables