tags:

views:

24

answers:

1

Hi all, my app has a styles.xml file with various visual constants defined.

I'd like my users to be able to switch the entire app to an alternative visual theme. I'd like to provide an alternative styles2.xml file and switch at runtime (via the Settings).

Is this possible, and how? I suspect the style names' appearance in the generated R class does not bode well.

If it's not possible, what's my next best option?

+1  A: 

Actually, after some reading of the doc, it seems that this can be done. Look here. As it is mentionned :

To create a set of styles, save an XML file in the res/values/ directory of your project. The name of the XML file is arbitrary, but it must use the .xml extension and be saved in the res/values/ folder.

Now, if this is logical and I didn't read the doc wrongly, you can create as many styles as you want, reference them in themes.xml with @style/... (if you want to apply it to a whole activity or application) and then, just call

setTheme(R.id.yourtheme)

I think this should work. Have a go at it and tell us?

Sephy
Looks promising Sephy I'll give it a go.
Jim Blackler