开发者

What's the meaning of the first line in an Android XML file?

开发者 https://www.devze.com 2023-02-24 12:34 出处:网络
Why do we write xmlns:android=\"http://schemas.android.com/apk/res/android\" in a开发者_C百科n Android XML file?It is a namespace definition. With this attribute you tell what schema(tag names, their

Why do we write xmlns:android="http://schemas.android.com/apk/res/android" in a开发者_C百科n Android XML file?


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.


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"


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

0

精彩评论

暂无评论...
验证码 换一张
取 消