xmlns:android的作用

1.xmlns:android是一个XML命名空间,告诉Android开发工具你准备使用Android命名空间里的一些通用属性。在所有Android XML设计文件中最外层的标记必须使用这个树形。

它可以提示你输入什么,不该输入什么,什么是对的,什么是错的,也可以理解为语法文件。或者语法判断器什么的。

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/text"
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center_vertical|center_horizontal" 
    android:text="translucent_background" 
    /> 

 <?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.com.fblife" 
    android:versionCode="1" 
    android:versionName="1.0"> 
         ...... 
</manifest> 
2.
当然在android Developers(开发者文档)中也有写到,

Interface for read only XML Namespace context processing.

An XML Namespace has the properties:

  • Namespace URI: Namespace name expressed as a URI to which the prefix is bound
  • prefix: syntactically, this is the part of the attribute name following theXMLConstants.XMLNS_ATTRIBUTE ("xmlns") in the Namespace declaration

example:<element xmlns:prefix="http://Namespace-name-URI">

在这我就不翻译了,不过从最后的一个example中我们可以看出,这类似是一个xml中的属性文件。

你可能感兴趣的:(xmlns:android的作用)