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中的屬性文件。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章