Custom Attributes in Android

这一生的挚爱 提交于 2019-12-03 10:26:26

If you are going to use an attr in more than one place then put it in the root element inside the <resources> element like the following :

<resources>

    <attr name="tag" format="string" />

    <declare-styleable name="Spinner">
        <attr name="tag" />
    </declare-styleable>

    <declare-styleable name="EditText">
        <attr name="tag" />
    </declare-styleable>

</resources>

Now you can use the tag attribute in anywhere you want inside this xml file .

Hope That Helps.

Rich Schuler

See if my detailed answer about custom attributes helps: Defining custom attrs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!