To use layout_marginLeft in a button style applied as a theme?

Viewed 15461

I used an attribute layout_marginLeft="30dip" in a style defined for buttons. When I apply this style individually for each button, the left margin is placed as I wanted.

But then I defined a theme, where I assigned my button style to the attribute android:buttonStyle and applied it to my project.
However, the left margin property is ignored. Any idea what I must do here?

style.xml as follows:

<style name="btnstyle" parent="@android:style/Widget.Button">
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_marginLeft">30dip</item>
    <item name="android:textColor">#FFFFFF</item>       
</style> 

<style name="appstyle" parent="android:Theme"> 
    <item name="android:buttonStyle">@style/btnstyle</item> 
</style>
5 Answers

Ever get to the bottom of this? I'm having the same issue; all margin attributes are ignored when applied to a Button or ImageButton via a style within a theme.

However, I've found it does work when the style is applied directly using the "style" attribute on the button. It seems that margins are not part of the "buttonStyle" spec.

Related