5

Why do Android xml layout files need android: before every single view attribute? Doesn't the system know it's Android? If the word is indeed redundant, it would seem that omitting it would save a good fraction of the memory required by these files, not to mention typing by programmers.

secretformula
  • 6,414
  • 3
  • 33
  • 56
JohnK
  • 6,865
  • 8
  • 49
  • 75

1 Answers1

6

It's used to specify that an element or attribute is part of that XML namespace. You can create your own namespaces for your own custom components (and often you will see them with 3rd party libraries). So in that regard, it's not redundant because it prevents name clashes.

Tyler Treat
  • 14,640
  • 15
  • 80
  • 115
  • Thanks, Tyler. I haven't created my own custom components or used a 3rd-party library before. I found this [helpful article on improving app appearance](http://stackoverflow.com/questions/5296767/android-how-can-i-improve-the-look-of-an-app). Are there any component libraries you would particularly recommend? – JohnK Jun 21 '12 at 13:30
  • 1
    I've used various open source widgets that you can find on GitHub or Google Code. One particular library I like is DroidFu, which has some really nice components such as `WebImageView`. This is an example of a library which defines its own namespace, e.g. `droidfu:imageUrl="http://www.android.com/images/opensourceprojec.gif"`. – Tyler Treat Jun 21 '12 at 14:19