Published in


Time to have a DARK Side

Photo by Andrew Hughes on Unsplash

This article has nothing to do with a philosophical approach to have some kind of a dark side of yourself. It is just about Android development, which is a serious business.

There are multiple ways to implement a custom dark theme in Android. (what a surprise(!) ) The one that I am going to explain is the one that looks the cleanest of them all to me. Of course, different approaches would be useful for different needs. So have a look at this cool google guide.

You need an alternative resource file for colors just to be used in dark times. It is like having a localization file for different languages. Here is how;

  • Right-click on your ‘res’ folder and select ‘New -> Android Resource File’
  • Put ‘colors’ as your file name (I know you already have a colors file.)
  • Select ‘Night Mode’ from “Available Qualifiers” list
  • Click on the ‘>>’ button
  • Select ‘Night mode’ as ‘Night’ from the spinner.
  • Click “OK”

That’s it. You have the resource file to override whatever color you want to override when the user device is in the dark mode.

Night mode colors creation

I have two items in my two colors files. They have the same name in two different files. I use those names for the background color and the text color of my text view. As you can see, I also have themes.xml files in values and values-night folders. You may have different whatever resources you want in your values-night folder.

Here are my color items;


<color name="backgroundColor">#ffffff</color>
<color name="textColor">#000000</color>


<color name="backgroundColor">#000000</color>
<color name="textColor">#ffffff</color>

Classic black/white…

This would not be the way to go for you but it is pretty straight forward. You can build a much better structure for your application with the help of the themes and theme attributes. You should definitely check out this talk for further understanding. Feel free to ask or share anything.

Light Version
Here is the Dark one




The (retired) Pub(lication) for Android & Tech, focused on Development

Recommended from Medium

MVC vs Razor Pages — A quick comparison

How to nail a technical interview (and get a technical interview)

Ultimate Guide to passing Java 11 Certification v.2021–09

Istio Authentication -Part 1

My Multi hybrid Cloud Task 1 :

Migrating from Jenkins to Azure DevOps

Migrating from Jenkins to Azure Devops

Ultimate emacs setup with documentation in org mode

Voice Notifications Automated | Python

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
efe budak

efe budak

Android Developer

More from Medium

Espresso UI Testing for Intents in Android

Prep your TV app for Android 12

OpenGL ES: Render A 2D texture in Android App

[요약] Google I/O 2022 What’s new in Jetpack