F
F
firexel2011-10-12 22:01:56
Android
firexel, 2011-10-12 22:01:56

Skins for android application

I've been fighting for a week now and I still can't solve this problem:

Let's assume that there is already a well-established interface of a certain program for android. At the same time, all layouts are rendered in xml. How can I now attach skins / skins / themes to this application that change background pictures and colors?
I’ll immediately note that the internal theme mechanism is not suitable for a fairly obvious reason: it is not possible to set different parameters for different instances of the same class. Those. if we set something like

<style name="someTheme" parent="android:style/Widget.Button">
   <item name="android:background">@drawable/some_drawable</item>
</style>
then the specified background will be applied to all instances of the Button class, which is not allowed with the current layout.
Also, I tried wrapping
Resources.getDrawable(int)
It did not help in any way - the resources specified in xml are loaded bypassing this method.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
palmut, 2011-10-13
@palmut

Why can't attributes be used for this purpose? Put background images and colors that are specific to the theme into attributes and redefine these attributes in the themes. Next, we use the standard theme switching mechanism.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question