Android: How do you have multiple attr with the same enum?

I have attr defined as an enum with a list of values:

<attr name="font" format="enum">
    <enum name="AvenirMedium" value="1" />
    <enum name="AvenirBlack" value="2" />
</attr>

      

I would like to use multiple attr with different names inside the same.

For example:

<declare-styleable name="CustomView">
    <attr name="font" />
    <attr name="leftFont" />
    <attr name="rightFont" />
</declare-styleable>

      

Instead of defining an enum multiple times, I'm trying to find a way to define an enum once, but in order to have a font, leftFont, rightFont all using the same list of enums.

Does anyone know how this can be done?

Edit: I am well aware of how to define attr globally and reference it in multiple declarations. This question is about using enum in multiple attr with different names.

+3


source to share


1 answer


Since the name is only the attr parameter that serves as a key, the answer is no .. umfortunetly not possible ..



You should make identical enums with different names.

0


source







All Articles