现在的位置: 首页 > 综合 > 正文

res与res-auto的区别

2018年04月01日 ⁄ 综合 ⁄ 共 673字 ⁄ 字号 评论关闭

Issue 9656: Library projects don't support custom XML attributes for custom classes

Solution:

Upgrade to latest SDK & ADT version (fixed was released since r17) and usehttp://schemas.android.com/apk/res-auto as
custom attributes' namespace URI, see Revisions for ADT 17.0.0:

Added support for custom views with custom attributes in libraries. Layouts using custom attributes must use the namespace URI http://schemas.android.com/apk/res-auto instead
of the URI that includes the app package name. This URI is replaced with the app specific one at build time.

res与res-auto的区别

通常我们在布局文件中使用自定义属性的时候
会这样写

xmlns:app="http://schemas.android.com/apk/res/包路径"

但如果你当前工程是做为lib使用,那么你如上所写 ,会出现找不到自定义属性的错误 。
这时候你就可以 写成

xmlns:app="http://schemas.android.com/apk/res-auto"

抱歉!评论已关闭.