Android 自定义属性重复:../attrs.xml: Error: Found item Attr/rightTextColor more than one time

自定义属性时,对于不同的 属性域,采用了相同的属性名,会引发错误:
../attrs.xml: Error: Found item Attr/rightTextColor more than one time

<declare-styleable name="s1">
	<attr name="rightTextColor"  format="color"/>
</declare-styleable>

<declare-styleable name="s2">
	<attr name="rightTextColor"  format="color"/>
</declare-styleable>

解决:
将属性定义在外部,内部只声明引用。

<attr name="rightTextColor" format="color" />

<declare-styleable name="s1">
	<attr name="rightTextColor"/>
</declare-styleable>

<declare-styleable name="s2">
	<attr name="rightTextColor"/>
</declare-styleable>
发布了400 篇原创文章 · 获赞 364 · 访问量 162万+

猜你喜欢

转载自blog.csdn.net/jjwwmlp456/article/details/102796860