当我们在 Android 中编写基于 xml 的布局时,我们使用字符串 "xmlns:android="http://schemas.android.com/apk/res/android"。
从我读过的书中说这是一个命名空间,但我们为什么要使用它呢?该链接甚至不存在。那么这个有什么用呢?
最佳答案
来自 developer.android.com
xmlns:android
定义 Android 命名空间。此属性应始终设置为“http://schemas.android.com/apk/res/android”。
xmlns:android 用于标识此xml用于android,而不是用于其他功能。
命名空间唯一标识代码/库。如果我编写一个使用所有相同名称的 api,例如 android api,那么区分我的 api 和 android api 的唯一方法是使用 android 命名空间,或者我的。
关于android - 为什么我们在 android xml 文件中指定命名空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5856719/