Reputation: 756
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
Upvotes: 0
Views: 1036
Reputation: 24114
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.
Upvotes: 1
Reputation: 12552
You also need to call yourAppCompatActivity.getDelegate().applyDayNight();
.
Upvotes: 1