Reputation: 1
Why do we write xmlns:android="http://schemas.android.com/apk/res/android"
in an Android XML file?
Upvotes: 0
Views: 299
Reputation: 3319
This is an explicit namespace declaration. Just as two classes can have the same name, they will have different fully qualified names, two xml tags can have the same name,, but different fully qualified names. Just as it is common to use com.mycompany as a package name, it is common to declare http://some.unique.id to declare an xml namespace. The form is xmlns:Prefix="namespace" where Prefix is a alias so that android:icon is an alias to http://blah.blah.blah.icon. Anyway, that is my understanding.
JAL
Upvotes: 2
Reputation: 43088
It is a namespace definition. With this attribute you tell what schema(tag names, their attributes and so on) you're using within the file. Read more.
Upvotes: 3
Reputation: 11571
xmlns:android defines the Android namespace. This attribute should always be set to "http://schemas.android.com/apk/res/android". The root element in xml needs to declare the Android XML namespace:
xmlns:android="http://schemas.android.com/apk/res/android"
Upvotes: 2