Alexander Oleynikov
Alexander Oleynikov

Reputation: 19388

Multi theme support in android app

Did anyone implemented multi theme support for android app? Are there any common practices for this?

Thanks for any advice.

UPD: The main problem for now is that android's theme engine doesn't support selectors like in CSS. For example if I have two views with "background" attribute there's no way to make theme engine distinguish those ones and set different backgrounds. I can specify different style for each view but this approach lacks flexibility 'cause it's impossible to apply style for whole activity at once.

Upvotes: 1

Views: 4435

Answers (1)

Sephy
Sephy

Reputation: 50442

As far as I know, there is no way to set a theme to the whole application in on line of code. If you want to change the theme of an activity, you need call setTheme() in its onCreate() method, BEFORE calling setContentView. So to make it easier for you, you could do a switch on all your themes, and select one in regards of what the user has selected. Now, if you want it to apply easily to all your activities, you could make all your activities be a subclass of a custom Activity in which you would only set the theme. Activity <-- ThemeActivity <-- all your Activities

Upvotes: 3

Related Questions