5

I'm mainly using the Android emulator for development. Is there a quick way (ideally a keyboard shortcut) to switch between dark mode and light mode for testing the dark/light themes?

don
  • 1,497
  • 1
  • 13
  • 27
  • I am hoping for a solution similar to the one for this question: https://stackoverflow.com/questions/59886562/is-there-a-keyboard-shortcut-to-switch-between-dark-mode-and-light-mode-in-iphon – don Aug 05 '21 at 20:51
  • Not on the emulator but on the layout editor you can just press `N` – javdromero Aug 05 '21 at 20:53
  • 2
    You should be able to add the dark mode tile in the notification shade, as you do with an actual device. – CommonsWare Aug 05 '21 at 21:10

2 Answers2

5

Just to bring more visibility to the comment above with a great solution:

You should be able to add the dark mode tile in the [swipe down] notification shade, as you do with an actual device.

Obviously it will change slightly depending on the phone you are emulating but here is a demo for anyone not used to Android devices

dark mode in notification shade demo

australis
  • 431
  • 5
  • 10
2

If you use MacOS, you can automate this action with a shortcut:

  1. Open Shortcuts.app
  2. Find action "Run shell script"
  3. Insert this script:
alias adb="/Users/YOUR_USERNAME/Library/Android/sdk/platform-tools/adb"
if [[ $(adb shell "cmd uimode night") == "Night mode: yes" ]]; then
  adb shell "cmd uimode night no"
else
  adb shell "cmd uimode night yes"
fi

  1. Select "Shortcut details" tab on the top right ("i" icon), click Add keyboard shortcut and add your shortcut.

Here is an example:

shortcuts example

Works perfectly!

shortcut gif

pavelperc
  • 119
  • 5