Pages

Monday 27 April 2015

Same-named attributes in attrs.xml for custom view

Simply extract common attributes from both views and add them directly as children of the <resources>  node:
For Example

<resources>
    <attr format="string" name="myattr1">
    <attr format="integer" name="myattr2">

    <declare-styleable name="customView1">
        <attr name="myattr1">
        <attr name="myattr2">
        ...
    </attr></attr></declare-styleable>

    <declare-styleable name="customView2">
        <attr name="myattr1">
        <attr name="myattr2">
        ...
    </attr></attr></declare-styleable>

<!-- if want to use one attar -->
 <declare-styleable name="customView3">
        <attr name="myattr1">
      
        ...
    </attr></declare-styleable>
</attr></attr></resources>

No comments :

Post a Comment