I constantly have to manually the layout parameters to my buttons
<Button
android:id="@+id/signIn"
android:layout_above="@+id/forgotPassword"
android:text="@string/button_sign_in"
<!-- Repetitive part -->
android:layout_marginLeft="@dimen/button_margin_left"
android:layout_marginRight="@dimen/button_margin_right"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
My styles.xml
<style name="myButton" parent="android:style/Widget.Button">
<item name="android:textColor">@color/button_textColor</item>
<item name="android:background">@drawable/button_background</item>
<item name="android:textSize">@dimen/button_textSize</item>
<item name="android:padding">@dimen/button_padding</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_marginLeft">@dimen/button_margin_left</item>
<item name="android:layout_marginRight">@dimen/button_margin_right</item>
</style>
However the last three values seem to have no affect! If I can't set it in the styles xml, can I set up eclipse to change the default values it creates when using the graphical layout?
I didn't have room in the comments section, so here's my (working) code, for a TextView
<TextView
android:id="@+id/show_sa_j"
style="@style/show_title"
android:text="@string/loading" />
<style name="show_title">
<item name="android:textSize">34dp</item>
<item name="android:textColor">#FFFFFFFF</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:paddingLeft">10dp</item>
<item name="android:paddingRight">10dp</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
The result is:

As you can see, the TextView is filling its parent in width (minus the parent's padding).
Just to prove that layout margin works aswell, I added <item name="android:layout_marginLeft">25dp</item> to my styles and here's the result:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With