How to disable night mode in my application even if night mode is enable in android 9.0 (pie)?

前端 未结 8 932
悲&欢浪女
悲&欢浪女 2020-12-16 12:32

I created my application before the android pie has been released, in every layout I put android: background = \"white\" it works fine in every device, but when

8条回答
  •  生来不讨喜
    2020-12-16 12:57

    If you want to avoid Activity recreations you could set the flag on the Application class as mentioned here

    I recommend setting it in your application class (if you have one) like so:

    public class MyApplication extends Application {
        
        public void onCreate() {
            super.onCreate();
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
    }
    

提交回复
热议问题