Can I use my own resource names in themes.xml? For example:
<item name="headerBackground">@drawable/header</item>
In this example, headerBackground is not a valid resource (No resource found that matches the given name..., says Eclipse).
Where should I create/declare these resources? Is this a bad idea?
Of course you can use your own names, otherwise you’d be stuck with the Android default drawables.. 🙂
You declare drawable names by placing a file with that name in your
res/drawabledirectory.Updated, actual answer:
You need to declare a styleable attribute, in
res/values/attrs.xml(the actual filename doesn’t matter, but this seems to be the convention):Then you can assign it a value in your theme, for example:
Of course whatever
Viewyou’re implementing to use this newly-defined attribute has to be able to load thatDrawableand apply it. The Gallery example on the Android Developers’ site is useful there.