Image for post
Image for post

Why support dark theme?

Quick start

#1: Change your theme

<style name="Theme.MyApp"
parent="Theme.MaterialComponents.DayNight">
<!-- Other theme attributes --></style>

#2: Choose what mode to be in (optional)

Image for post
Image for post
Example in-app dark theme setting

#3: Test!

Material Dark Theme

Grey vs black

Color palette

Recap on Material color system

Image for post
Image for post
Baseline Material color palettes

colorPrimary

Image for post
Image for post

colorSecondary

Surface colors

Image for post
Image for post
Don’t do this. Demo showing a bottom app bar with a vivid surface color

Use primary surface

<com.google.android.material.bottomappbar.BottomAppBar
style="Widget.MaterialComponents.BottomAppBar.PrimarySurface" />
<FrameLayout
android:background="?attr/colorPrimarySurface" />
Image for post
Image for post
Examples showing the PrimarySurface and styles and attribute

Branded surface color

Image for post
Image for post
How to calculate a branded surface color

Crafting dark theme example

Image for post
Image for post
Theme structure which works well for dark themes
values/themes.xml
values-night/themes.xml

Elevation overlays

Image for post
Image for post
Demo showing elevation overlay at different elevation levels

Widget support

Custom views


OK Google, goodnight 🌚

Android Developers

The official Android Developers publication on Medium

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

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