Tag Archives: Error: Found item Attr/tabText

Android Error: Found item attr/tabtextsize more than one time

cause

I’m at RES/values/atts.xml The tabtextsize attribute is defined in the file. There is no problem when using it, but in the process of compiling, I produced error: Found item attr / tabtextsize more than one time , which means error: Found item attr / tabtrimescribe defined more than once , at the beginning, I was puzzled, so I went to see the attributes defined in attr. Find the following as shown:

<resources>
    <declare-styleable name="View Name">
        <attr name="tabTextSize" format="float"/>
        <attr name="tabTextSelectedColor" format="color" />
        <attr name="tabTextUnselectedColor" format="color" />
     </declare-styleable>

    <declare-styleable name="View Name">
        <attr name="tabTextSize" format="float"/>
        <attr name="tabTextSelectedColor" format="color" />
        <attr name="tabTextUnselectedColor" format="color" />
    </declare-styleable>
</resources>

Since the custom view property name is the same, the error mentioned above occurred.

How to Fix

The solution is to extract the same attribute and define it. As shown below, <attr name="tabTextSize" format="float" />is extracted and then called in each view.

<resources>
    <attr name="tabTextSize" format="float"/>
    <declare-styleable name="View Name">
        <attr name="tabTextSize" />
        <attr name="tabTextSelectedColor" format="color" />
        <attr name="tabTextUnselectedColor" format="color" />
    </declare-styleable>

    <declare-styleable name="View Name">
        <attr name="tabTextSize"/>
        <attr name="tabTextSelectedColor" format="color" />
        <attr name="tabTextUnselectedColor" format="color" />
    </declare-styleable>
</resources>