【发布时间】:2020-02-21 11:32:27
【问题描述】:
如果我导入:
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 重复,这将失败。我以为 Android 会通过 declare-styleable name 来区分,但我猜不是。话虽如此,命名自定义视图 attr 以避免将来任何可能的重复值冲突的最佳方式是什么?
目前我得到的唯一解决方案是:
<attr name="minForMyCustomViewHopingNoOneUsesThisName" format="float"/>
这太糟糕了。
【问题讨论】:
-
在引入命名空间之前,这是我们唯一的选择。
标签: android android-custom-view android-styles android-attributes