Custom Attributes in Android Custom Attributes in Android android android

Custom Attributes in Android


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.


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