When using prefixes in XML, a so-called namespace for the prefix must be defined. The namespace is defined by the xmlns attribute in the start tag of an element. The namespace declaration has the following syntax. xmlns:prefix="URI".
Note: The namespace URI is not used by the parser to look up information.
The purpose is to give the namespace a unique name. However, often companies use the namespace as a pointer to a web page containing namespace information.
I think it makes clear with the namespace, as we can create our own attributes and if the user specified attribute is the same as the Android one it avoid the conflict of the namespace.
It is a XML name space declaration in order to specify that the attributes that are within the view group that it's decelerated in are android related.
To understand why xmlns:android=“http://schemas.android.com/apk/res/android” must be the first in the layout xml file We shall understand the components using an example
XML namespaces are used for providing uniquely named elements and
attributes in an XML document. xmlns:android describes the android
namespace.
Its used like this because this is a design choice by google to
handle the errors at compile time.
Also suppose we write our own textview widget with different
features compared to android textview, android namespace helps to
distinguish between our custom textview widget and android
textview widget
In XML, element names are defined by the developer. This often results in a conflict when trying to mix XML documents from different XML applications. A user or an XML application will not know how to handle these differences. Name conflicts in XML can easily be avoided using a name prefix. When using prefixes in XML, a namespace for the prefix must be defined.The namespace can be defined by an xmlns attribute in the start tag of an element.The namespace declaration has the following syntax. xmlns:prefix="URI".
xmlns refers to the XML namespace
When using prefixes in XML, a so-called namespace for the prefix must be defined. The namespace is defined by the xmlns attribute in the start tag of an element. The namespace declaration has the following syntax. xmlns:prefix="URI".
Note: The namespace URI is not used by the parser to look up information.
The purpose is to give the namespace a unique name. However, often companies use the namespace as a pointer to a web page containing namespace information.
xmlns:android Defines the Android namespace. This attribute should always be set to "http://schemas.android.com/apk/res/android".
refer http://developer.android.com/guide/topics/manifest/manifest-element.html
I think it makes clear with the namespace, as we can create our own attributes and if the user specified attribute is the same as the Android one it avoid the conflict of the namespace.
It is a XML name space declaration in order to specify that the attributes that are within the view group that it's decelerated in are android related.
To understand why
xmlns:android=“http://schemas.android.com/apk/res/android”
must be the first in the layout xml file We shall understand the components using an exampleSample
::Uniform Resource Indicator(URI):
Ex:
http://schemas.android.com/apk/res/android:id
is the URI hereXML Namespace:
xmlns:android
describes the android namespace.textview
widget with different features compared to androidtextview
, android namespace helps to distinguish between our customtextview
widget and androidtextview
widgetIn XML, element names are defined by the developer. This often results in a conflict when trying to mix XML documents from different XML applications. A user or an XML application will not know how to handle these differences. Name conflicts in XML can easily be avoided using a name prefix. When using prefixes in XML, a namespace for the prefix must be defined.The namespace can be defined by an xmlns attribute in the start tag of an element.The namespace declaration has the following syntax. xmlns:prefix="URI".