您的位置:首页 > 移动开发 > Android开发

Android Library Project自定义控件属性无法找到说明

2014-03-01 14:41 423 查看
在使用Android Library Project的时候,使用了自定义控件,命名空间我们通常会使用包名作为后缀
http://schemas.android.com/apk/com.custom.pkg, 然而子工程引用的时候却一直报错无法找到某某控件属性,查阅资料后发现,如果在Library Project里使用自定义控件的话,必须使用如下的命名空间 xmlns:custom="
http://schemas.android.com/apk/res-auto ",custom名字可以任取。以下是来自Google group上的讨论,在SDK release not应该也能看到。
It was closed because it was actually solved. Take a look into "what's new in sdk r17":

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-auto,原因是build的时候会将它体会为包名http://stackoverflow.com/questions/4461407/help-with-a-custom-view-attributes-inside-a-android-library-project/10217752#10217752
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: