Android Dark Mode

Dark theme is available in Android 10 (API level 29) and higher

To Enable Dark Mode search in the notification tray or open Device system Settings -> Display -> Theme

Benefits:

  1. Saves Battery power.
  2. easy to see in low-light environments.
  3. help dealing with sensitive eyes.

Develop Dark theme enable app

make your manifest Application use theme that inherit from

Theme.AppCompat.DayNight
or
Theme.MaterialComponents.DayNight

Colors

  1. You will need “values-night” folder in res folder with themes.xml & colors.xml
  2. You can have also drawable-night folder!
  3. You can try to avoid hard coded colors.
  4. Need to use precise hex color, you can have two colors.xml files one in “value” folder and one in “values-night” folder.


For example you can have a textview which has textColor that has been defined in that 2 colors files under the same key, i each file the color value is deferent and theme suitable.

Icons

Beside color changes – the designer should Go over All App Icons And adjust them to the night theme as well.
the designer can demand using set of icons for night theme.
you can use drawable-night folder or the code below to recognise the current theme

‎‎

Button Click To force Dark mode to your app

‎‎

When a user change the the device theme All Apps Activities will get recreated
if you want to get notify you should follow code below


Don’t forget to test notifications and launcher Icon design.

As been mention when user start using dark mode the Activity will get recreated – so test this for some saving state bugs

Leave a Reply