On the project I am currently developing I wanted to keep two versions of the UI, black and white. I was looking for an easy way to define just the differences, but in the same time to keep the common definitions in one place.
In following layouts the text size, shadow radius and position are common to both styles and I am customizing only text and shadow color.
The key to the success is custom attribute in the
Now I can provide alternative behavior for this attribute in my themes:
The last piece to te puzzle is the UI element definition itself and its reference to my custom attribute:
I've set up the project on my Bitbucket repository so that you can have a look at all sources. Project even contains switching between themes in the runtime, but I did not find the nice way to do that yet, so it is always restarting the activity and it does not apply to the whole application. If you know how to do this in better, I would appreciate some tips.