0

I want to have a night mode/day mode theme in my app. Currently, I have all screens with day mode.

I have 80+ very complex layout files, 20+ styles defined (7 kinds of text, spinners, etc).

Option 1: Have another set of layouts with _night prefix, referencing _night styles would be a lot of work.

Option 2: switch out colors in runtime..too much work

Is there an easy way to define another theme?

Tamas
  • 360
  • 1
  • 4
  • 13

1 Answers1

0

You can set theme in your Activity before setContentView is called. Something like this.

public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState);
    setTheme(your theme here);
    setContentView(...) 
} 

If a user changes theme within an Activity then you have to restart that Activity to see the change.

http://developer.android.com/reference/android/view/ContextThemeWrapper.html#setTheme(int)

Sharjeel
  • 15,588
  • 14
  • 58
  • 89