Darkness is coming. Prepare your Android App to support Dark Mode

No Dark mode = Horrible UX

If you have migrated to Android 10 and have not done any changes in your app then even if the user has enabled the dark mode system-wide, it does not affect your app in any way. It just creates super weird UX because of your wonky decision for ignoring dark mode. If user is surfing through apps, opens your app which does not support dark mode then user suddenly gets super bright light blinding the eyes!

Quick and dirty way

If dark mode is the least important thing you care about your app and don’t want to spend any efforts implementing this then adding a single line in your app theme is all it takes. Rest system takes care of it for you.

Light mode on left and forced dark mode on right

Implementing in Legitimate and Pristine way

In order to support Dark theme, you must set your app’s theme (usually found in res/values/styles.xml) to inherit from a DayNight theme:

<style name="AppTheme" parent="Theme.AppCompat.DayNight">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
forced dark mode on left vs customised dark mode on right
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<item name="android:colorBackground">@color/backgroundDark</item>
<item name="textColorPrimary">@color/textColorPrimaryLight</item>
</style>
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<item name="android:colorBackground">@color/backgroundLight</item>
<item name="textColorPrimary">@color/textColorPrimaryDark</item>
</style>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store