The System Override Solution

You could try to cheat a bit and have the system create a dark theme for you on the fly. For that, add this entry to your theme resource:

<item name="android:forceDarkAllowed">true</item>

Then, on Android 10 and higher devices, the system will examine your UI and swap colors to try to make the app appear dark. It even has the smarts to determine whether an ImageView appears to be containing an icon (that might be converted) or a photo (that should not be converted).

So, in the default mode, you might have:

Sample App, in Normal Mode
Sample App, in Normal Mode

…while if the user opts into the dark mode, android:forceDarkAllowed="true" will give the user:

Sample App, in Force-Dark Mode
Sample App, in Force-Dark Mode

This is quick and easy. However:


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.