how to change theme of app in android studio programmatically
So, to switch between themes dynamically you simply need to call setTheme before super.onCreate like this: public void onCreate(Bundle savedInstanceState) { setTheme(android.R.style.Theme); super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); }
Here is what the above code is Doing:
1. The first line of code is calling the setTheme method.
2. The second line of code is calling the super.onCreate method.
3. The third line of code is calling the setContentView method.