addisonElliott / SegmentedButton

Segmented Control/Button with animation for Android API 16+
Apache License 2.0
148 stars 39 forks source link

Add prefix to custom attributes #55

Closed piphagor closed 2 years ago

piphagor commented 3 years ago

This is a constant problem in Android. Attributes do not have name spaces. Attributes of the same name must have the same type. To make this library bullet-proof and to avoid possible conflicts with other libraries segmentedButton_ and segmentedButtonGroup_ prefixes were added.

Additionally, in my opinion, it's easier to read long xml files when custom attributes have a prefix and give an idea from which library they are coming from.

addisonElliott commented 3 years ago

I'm not sure I understand the issue of not having prefixes. This was something the original library that I removed when I forked it.

The custom attributes are only applicable for the SegmentedButton and SegmentedButtonGroup components. To have an issue, a custom attribute must be added that conflicts with the ones defined in this library for SegmentedButton and SegmentedButtonGroup. How often is that going to happen?

piphagor commented 3 years ago

This is an Android problem. All custom attributes from the whole project are merged to one file, and there is a rule: Attributes of the same name must have the same type.

Therefore, if two libraries introduced the same attribute, let's say position, but one library uses format="integer" and another one format="enum", Android will throw something like:

AAPT: error: duplicate value for resource 'attr/position' with config ''

Taking into account modern Android development, you could have dozens of libraries, and you never know which attribute could be duplicated. Especially ones with common names, like radius, position, divider, etc.

To make it bullet proof for the future, I recommend to bring back prefixes.

piphagor commented 2 years ago

Hi @addisonElliott! Could you have a look? I updated prefixes to ones, used in the original library.