Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Implementing Designs for Android Customizing the Login Screen Adding the Login Background Image

values>colorS.xml BUT from layout xml we assign "@color"... why?

Hi guys and gals!

Just noticed something. In our values folder we have files like strings.xml, colors.xml, dimens.xml, etc. Notice that the filenames end in "s".

In our layout xml files, if we want to access/assign one of the attributes of the above mentions files we use "@string/..." or "@dimen/..." or "@color/..."

What happened to the "s"? o.O

3 Answers

Also to add to Calvins answer if you look in the XML, the file is set as a resource and each item has an assigned data type of "string" "id" and "color" which does not have the 's'

The file name is separate from the data type.

Hi Masum,

You are very observant!

I believe this is because you are only accessing one of the attributes. Hence, it would not be plural, so that is why there is no "s".

Strings.xml, Colors.xml, and Dimens.xml all contain "s" because they contain all of the "strings, colors, and dimensions". So they are plural.

Please let me know if this helps.

Ahhh... that makes sense... so when I assign an attribute in my layout xml, let's say "@color/..." I am referring to the <color> tag rather than the colors.xml file name. So in other words it doesn't matter what I name my files in the values folder. I suppose I could even just have a single file containing all of my attributes... granted it'd be messy but technically possible. (did I understand correctly?)

Thanks Calvin! Thanks Andres! That helped a lot!! Appreciate the super fast response!!

Hi Masum,

You are welcome!

Ummm I'm pretty sure that the file names don't matter (If I remember correctly, He even discusses this in later videos).

The file names that are set by default just make it easier to organize.

Now that you mention it, I vaguely remember Ben saying something to that effect in one of the vids of the Android Track! (I think!) ;-)

Yeah in theory you "could" add them all in one XML, but this is not best practice at all.