0

I've created a new project that only includes a very simple activity that uses the new Day/Night theme. Even when calling AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); in a static block on the application class AND calling getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); in the activity, the activity is showing the night theme. I've set a break point on the activity and its reporting that the UI mode is night, so I've got no idea why it's refusing to show the day theme.

I'm compiling against/targetting API 23 and testing on a Nexus 5 running Marshmallow

Tim Mutton
  • 756
  • 8
  • 17

2 Answers2

1

You also need to call yourAppCompatActivity.getDelegate().applyDayNight();.

Gaëtan
  • 11,912
  • 7
  • 35
  • 45
1

See https://code.google.com/p/android/issues/detail?id=201910. This will be fixed in the 23.2.1 bugfix release.

For now, you can force the theme to re-apply using the new configuration in your Activity.onCreate() by calling

getTheme().applyStyle(R.style.Theme_AppCompat_<whatever>, true);

where <whatever> is the theme that you're using in that activity. Once you update to 23.2.1, you will not need this workaround.

alanv
  • 23,966
  • 4
  • 93
  • 80