Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

dark mode
android
theme
community creator

Dark-mode support on your Android app

Chisom Nwokwu

Nobody enjoys white light right in front of their eyeballs, trust me, your users might want something a bit more soothing when moving through your Android Application.

Luckily, how to add dark mode support on your app is exactly what this article is about!

Step 1: Change the theme to DayLight.

In styles.xml, change the AppTheme parent theme from Light to DayNight:

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">

Step 2: Turn on the dark theme.

In MainActivity’s onCreate(), call AppCompatDelegate.setDefaultNightMode() to turn on the dark theme:

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)

There you have it – run the app and verify that it has switched to dark theme!

RELATED TAGS

dark mode
android
theme
community creator
RELATED COURSES

View all Courses

Keep Exploring