关于什么是:xmlns:tools="http://schemas.android.com/tools"

来源:互联网 发布:驱逐鞑虏恢复中华知乎 编辑:程序博客网 时间:2024/05/17 08:30

It defines the XML namespace of the document.

You should put it, otherwise tags like <RelativeLayout> could be not recognied by the parser.

Namespaces are a way for XML documents to include tags from various vendors.

By using xmlns attribute you declare, that, by default, you're using XML elements defined

here: http://schemas.android.com/apk/res/android (note that this link is broken -this discussion explains why).

You also declare additional namespace, tools, which is not your default namespace, thus when referencing elements or attributes defined there, you must addtools prefix, on example:

tools:context=".SomeActivity"
0 0