您的位置:首页 > 其它

自定义View里面的自定义属性的时候报错:Attribute "color" has already been defined

2016-03-26 19:36 351 查看
自定义属性的时候报错:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="NotePadView">

<attr name="color" format="color"></attr>
<attr name="lineHeight" format="dimension"></attr>
</declare-styleable>
</resources>


C:\AndroidStudioProjects\CustomerView\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\res\values\values.xml

Error:(2) Attribute "color" has already been defined

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1

因为color 这个属性默认的就是 有的,所以一定不能使用这个属性:

解决方法:

修改属性为其他的名字:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="NotePadView">

<attr name="lineColor" format="color"></attr>
<attr name="lineHeight" format="dimension"></attr>
</declare-styleable>
</resources>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: