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:
- Saves Battery power.
- easy to see in low-light environments.
- 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
- You will need “values-night” folder in res folder with themes.xml & colors.xml
- You can have also drawable-night folder!
- You can try to avoid hard coded colors.
- 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