我创建了一个自定义小部件,并在layout.xml中声明它。 我还在attr.xml中添加了一些自定义属性。 但是,当我尝试在styles.xml中的样式中声明这些属性时,它给出了No resource found that matches the given name: attr 'custom:attribute'
的错误信息。
我在styles.xml中的所有标记中,包括<?xml>
、<resources>
和<style>
中都加入了xmlns:custom="http://schemas.android.com/apk/res/com.my.package"
,但仍然出现相同的错误,无法找到我的自定义XML命名空间。
但是,我可以使用我的命名空间在layout.xml中手动为视图分配属性,因此命名空间没有问题。 我的问题在于让styles.xml意识到我的attr.xml。
cutsom:xmlns=...
?难道不应该是xmlns:cutsom=...
吗? - Selvin