如果我导入:
CustomViewA
<declare-styleable name="CustomViewA">
<attr name="min" format="float"/>
<attr name="max" format="float"/>
</declare-styleable>
CustomViewB
<declare-styleable name="CustomViewB">
<attr name="min" format="float"/>
<attr name="max" format="float"/>
</declare-styleable>
这将失败,说明min和max是重复的。我以为Android会以declare-styleable name
来区分,但我猜不会。如此说来,命名自定义视图attr
的最佳方法是什么,以避免将来出现任何可能的重复值冲突?
到目前为止,我唯一的解决方案是:
<attr name="minForMyCustomViewHopingNoOneUsesThisName" format="float"/>
糟透了。
使其独特是最终的答案。我准备使用
<attr name="custom_view_a_min" format="float"/>
<attr name="custom_view_b_min" format="float"/>