res-auto和com.package.name之间的xml命名差异-android [英] difference in naming xml between res-auto and com.package.name - android
本文介绍了res-auto和com.package.name之间的xml命名差异-android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到了带有的自定义xml:
I have seen custom xml with :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
和
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/com.package.custom"
这两个单独的名称之间有什么区别?
whats the difference between these two separate names?
- 后者是否仅像您的包裹一样指向默认位置?
- 前者是否指向参考文献lib?
谢谢.
推荐答案
如果我们在项目中添加新的自定义视图及其属性,则可以在布局的开头添加它:
If we add a new custom view and its attributes inside our project, you add this at the beginning of your layout:
xmlns:custom="http://schemas.android.com/apk/res/your_main_app_package
如果新的自定义视图位于链接到您的项目的库项目中,则添加以下内容:
If the new custom view is inside a library project linked to your project, you add this:
xmlns:custom="http://schemas.android.com/apk/res-auto
注意:此问题已在ADT修订版17+中得到解决.对于任何服务或活动,请按以下方式声明名称空间:
xmlns:custom="http://schemas.android.com/apk/res-auto"
后缀 res-auto
将在构建时用实际的项目包替换,因此请确保设置属性名称,以尽可能避免冲突.
The suffix res-auto
will be replaced at build time with the actual project package, so make sure you set up your attribute names to avoid collisions if at all possible.
这篇关于res-auto和com.package.name之间的xml命名差异-android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文