如果我进口:
CustomViewA (从Maven进口)
<declare-styleable name="CustomViewA">
<attr name="min" format="float"/>
<attr name="max" format="float"/>
</declare-styleable>CustomViewB (从Maven进口)
<declare-styleable name="CustomViewB">
<attr name="min" format="float"/>
<attr name="max" format="float"/>
</declare-styleable>如果说min和max是重复的,这将失败。我原以为安卓会与declare-styleable name区别开来,但我猜并非如此。这么说,为自定义视图attr命名的最佳方法是什么,以避免将来发生任何可能的重复值冲突?
到目前为止,我唯一的解决办法是:
<attr name="minForMyCustomViewHopingNoOneUsesThisName" format="float"/>这太糟糕了。
发布于 2020-02-21 11:44:31
你可以做到的
<attr name="min" format="float" />
<attr name="max" format="float" />
<declare-styleable name="CustomViewA">
<attr name="min" />
<attr name="max" />
</declare-styleable>
<declare-styleable name="CustomViewB">
<attr name="min" />
<attr name="max" />
</declare-styleable>发布于 2020-02-21 11:41:09
使它独一无二是最终的答案。我准备用
<attr name="custom_view_a_min" format="float"/>
<attr name="custom_view_b_min" format="float"/>https://stackoverflow.com/questions/60337829
复制相似问题