This is part of the Android UI & UX: Beyond the Basics learning path. View Path.
Who is this for?
Experienced Android developers eager to learn how to support Dark theme in their apps in both Android 10 as well as earlier versions of Android.
- Force Dark
- DayNight and MaterialComponent themes
- Following the system theme
- Night resources
- Support for pre-Android 10 devices and Battery Saver mode
- uiMode configuration changes
Part 1: Supporting Dark Theme
Set Force Dark
Before using a DayNight theme, learn how to use Force Dark as a transition step to supporting Dark Theme on Android 10.
Use DayNight Theme
Switch from Force Dark to instead use an AppCompat DayNight theme, so that the themes will work on earlier versions of Android, and then a MaterialComponents DayNight theme.
Add Night Resources
DayNight themes support a "night" resource qualifier within which you can use styles to customize the views of your app when in Dark theme mode.
Let your user choose to override the system setting and pick either a Light or Dark theme, and then let them follow the system setting so that the app theme switches with the system.
Fix the Details
Dive into the smaller details of supporting dark themes and polish your app in both Light and Dark modes.
Dark theme changes at the system level correspond to uiMode configuration changes. See how to let your UI manually handle the change to the system Dark theme setting.
Add Legacy Support
Go back to automatically following the system Dark theme setting, and then adapt your app to follow the Battery Saver setting on versions of Android before Android 10.