How can I change between night mode and light mode on Android Studio preview?

I’m starting to implement dark mode on my app and I’m using Theme.AppCompat.DayNight.NoActionBar. Everything is working fine on the device but I want to see the differences on the Android Studio so I don’t have to keep running the code in order to see the changes.

How can I switch the Android Studio Preview to show me the night mode vs light mode themes?

Thanks.

Edit: just to be clear, I want to show on Preview whatever I have on resource folders -night instead of the normal resource folder.

Answer

If you’re using the most recent version of Android Studio, you should see a dropdown titled with the default theme that you’re using when you’re in preview mode on the Design Editor. Click on that dropdown (the callout labelled “5”) to access the list of themes:

Toolbar callouts in the Design Editor

^ Image taken directly from the documentation.

You can then click on the “Orientation for Preview” icon (see callout “2”) to access a list of layout variants for the current layout. (See the documentation for more info on how to create a layout variant.)

For more info, check out the documentation for what the buttons on the toolbar are.