It doesn't actually matter - <attr>
and <dimen>
are both value resources, and you can put them in any file in the res/values
folder. They'll all be combined into the same set of resources, so the actual file you use is up to you! So you can do this if you want:
# res/values/whatever.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="someDimension">48dp</dimen>
<attr name="someColour" format="color"></attr>
</resources>
and it'll work exactly the same as if you used attrs.xml
and dimens.xml
. It's just convention to put attr
s and declare-styleable
things in a file called attrs.xml
, all your dimension resources in dimens.xml
, all your strings in strings.xml
...
But you don't have to do that, it's up to you! For example, you might want certain resource strings to be stored in a different file, for organisation (maybe they shouldn't be translated). Or maybe some values are common to all configs and you want those in a single file, and you want a separate file for the qualified stuff (that goes in folders based on API level, night theme etc)