在写自定义属性时,惊现如下类型错误
Error:In <declare-styleable> XXX, unable to find attribute...
AS报的具体错误如下图
unable to find attribute 错误.png原始代码如下
<declare-styleable name="StepFive">
<attr name="circleSmallDoneColor"/>
<attr name="circleSmallWillColor"/>
<attr name="circleBigColor"/>
<attr name="hookColor"/>
<attr name="wordColor"/>
<attr name="lineSmallDoneColor"/>
<attr name="lineSmallWillColor"/>
<attr name="lineBigColor"/>
<attr name="currStep" format="integer" />
</declare-styleable>
后经过查询,是自己漏掉了相关的属性格式,将对应的属性格式(如:color)加上即可
修改后的代码如下
<declare-styleable name="StepFive">
<attr name="circleSmallDoneColor" format="color" />
<attr name="circleSmallWillColor" format="color" />
<attr name="circleBigColor" format="color" />
<attr name="hookColor" format="color" />
<attr name="wordColor" format="color" />
<attr name="lineSmallDoneColor" format="color" />
<attr name="lineSmallWillColor" format="color" />
<attr name="lineBigColor" format="color" />
<attr name="currStep" format="integer" />
</declare-styleable>
网友评论