I am developing an application that contains 2 themes and pictures which i use as skins. I can set the theme for the whole activty in the code. My problem is that I don’t know how to correctly separate the skins when it comes to pictures. For exemple, i have two themes (Black and White) and i have a set of pictures specific for these themes. How can I separate the pictures so i can set both the theme and the images for the skin from the code ?
Share
Sorry. I misunderstood the question. I have kept the previous answer below so that the comments have a natural flow.
In this case, what we have is a Branding.java class. This class takes in a brandname (Theme, in your case) and produces the various values and strings that would be uniques to that theme. So for example, you would name your Splash images dark_theme_splash.png and light_theme_splash.png. When loading that drawable you call Branding.getSplash() and it returns a drawable based on the current theme selected.
And in the branding you would have:
Then in your app you would have an int current_theme and set it to the theme you want on the fly.
*Below here is the old answer that answered a question that wasn’t actually asked *
I manage an app that has eight different themes. Some dramatically different. The best solution I have found for this so far is in two parts.
1.) Your build.xml. Since you are building different skinned apps, I imagine their .apk will be named differently. In your build.xml, take advantage of different targets. For example:
2.) This allows you to set different parameters for different builds. In my case, we had so many different drawables, it became cumbersome to manage them all within the various drawables folders. So in the drawable folders themselves, we put in all the common assets. Then created folders outside of the drawables that duplicated the drawable folder structure, but was contained within the theme’s name. For instance folder Themeone would contain Drawable, Drawable-hdpi etc. This allowed us to manipulate the build system in such a way that each specific target pulled only the drawables it needed.
All of this is contained in a for loop in build.xml that goes through the various build targets we have.
Hope that helps.