tags:

views:

61

answers:

1

Hi!

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.

+1  A: 

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

Sephy
Thanks. I've updated my original post. Maybe you can say something helpful now.
Aleksander O
I don't get your point about setting the style of a whole Activity... As i said above, setTheme sets the style for the whole activity.
Sephy
I'm sorry, just meant theme saying style when told about activity.So do you know any way to emulate CSS selectors in android themes?
Aleksander O
Well, I think that android themes and styles work pretty much the same way as selectors though with less, less options.
Sephy