Why getApplicationContext().setTheme() in a Activity does not work?

前端 未结 5 1643
广开言路
广开言路 2021-01-11 12:20

i am currently have a hard time for calling to getApplicationContext().setTheme() in a activity, I just want to apply a theme resource in a application scope in

5条回答
  •  囚心锁ツ
    2021-01-11 13:17

    I didn't try this out myself, but if it was absolutely necessary to set the theme programatically, the next thing I'd try would be to derive a class from Application and override the onCreate method like in the following:

    public class MyApplication extends android.app.Application {
        @Override
        public void onCreate() {
            super.onCreate();
            setTheme(android.R.style.Theme_Black_NoTitleBar_Fullscreen);
    
        }
    }
    

提交回复
热议问题