Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Masum Bergmann
PLUS
Masum Bergmann
Courses Plus Student 4,129 Points

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

Andres Mendoza
Andres Mendoza
3,088 Points

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.

Calvin Nix
Calvin Nix
43,828 Points

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.

Masum Bergmann
PLUS
Masum Bergmann
Courses Plus Student 4,129 Points

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!!

Calvin Nix
Calvin Nix
43,828 Points

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.

Masum Bergmann
Masum Bergmann
Courses Plus Student 4,129 Points

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!) ;-)

Andres Mendoza
Andres Mendoza
3,088 Points

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