jigar
jigar

Reputation: 1591

how to apply multiple Styles in android in same xml

Hi i have made an android program in that i have put a single nine path button for all the activities but i have applied one style for it but for other activities different styles for margin are needed...So. i have my one style as per below:So can i put another style for same element in same style.xml file? my code is as below:

<style name="button">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
         <item name="android:layout_marginLeft">30dp</item>
            <item name="android:layout_marginRight">30dp</item>
        <item name="android:layout_weight">1</item>
        <item name="android:tag">200</item>
        <item name="android:padding">7dp</item>
        <item name="android:textSize">15dp</item>
        <item name="android:textColor">#f5f0eb</item>
    </style>

Upvotes: 0

Views: 2740

Answers (1)

Henrik Christensen
Henrik Christensen

Reputation: 534

You can make a sub-style by doing something like this

<style name="otherButton" parent="button">  
    <item name="android:layout_marginLeft">50dp</item>    
...

This style inherits everything from its parent style. Everything you define in the sub-style will overrule any previously defined properties.

Upvotes: 1

Related Questions