Now, am trying to be a good Android developer and put all my textsize and other size specifications, and all the styles (like, say, button color, etc) in XML files. Am trying to read up on these. In a Stackoverflow thread, I read about dimens.xml. So I created a dimens.xml under each values- directory (like values-ldpi, values-mdpi, blah blah) and put one dimens.xml in each. It works fine. Now, I want to put some style information in the XML, like, a button color. Should I put the attribute in the same file i.e. dimens.xml? I read in one thread that dimens.xml is only for dimensions, and not for style related info. In another thread, I read that the name of the XML doesn't matter. Now, what is a good practice? Keep style.xml and dimens.xml separate ? Or put everything in one xml? And if, say, for a textview, I want to have both style (like color), and also textsize information in XML, then should I (1) put both color & textSize in styles.xml, or (2) put color in styles.xml and textSize in dimens.xml?
Asked
Active
Viewed 583 times
1 Answers
2
Keep style.xml and dimens.xml separate ?
As soon as style.xml already exists for reasons like these (button colors, text color, themes, etc.) then I believe that you should keep them separate.
And if, say, for a textview, I want to have both style (like color), and also textsize information in XML, then should I (1) put both color & textSize in styles.xml, or (2) put color in styles.xml and textSize in dimens.xml?
I would do the (2). (Although I can't blame anyone who would do the (1).). As far as I know there's no best practice guidance on that. I do it the (2) way basically because I see dimen.xml as a place to host pixel-related values. But this is my preference.

Thanos
- 3,627
- 3
- 24
- 35