okey guys, i've a button like the pict below
i want to change the distance between the text with the drawable . how to trick this one ?
this is my xml code for a button
<Button
android:id="@+id/ButtonCancel"
style="@style/CAGButton"
android:drawableLeft="@drawable/selector_ic_cancel"
android:text="@string/layer_button_cancel" />
and this is the CAGButton in style.xml
<style name="CAGButton" parent="@android:style/Widget.Button">
<item name="android:drawablePadding">3dip</item>
<item name="android:textColor">@color/cag_brown</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:background">@drawable/selector_button"</item>
</style>
okey, thanks in adv. :)
Btw i solved my problem with made some changes in my button style. so it become like this :
<style name="CAGButton" parent="@android:style/Widget.Button">
<item name="android:gravity">center</item>
<item name="android:paddingLeft">20dp</item>
<item name="android:paddingRight">20dp</item>
<item name="android:textColor">@color/cag_brown</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_weight">1</item>
<item name="android:background">@drawable/selector_button</item>
</style>
I think we just need to set the padding left &/ right to the best point that fit our design.
Here is the solution.
<Button
android:id="@+id/xyz"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:background="@drawable/button_shape"
android:drawableLeft="@drawable/location"
android:drawablePadding="2dip"
android:gravity="center"
android:paddingLeft="20dip"
android:paddingRight="16dip"
android:singleLine="true"
android:text="XYZ"
android:textColor="#FFF" />
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