Is it possible to set the margin or padding for the image which we added with the android:drawableLeft
?
As cephus mentioned android:drawablePadding
will only force padding between the text and the drawable if the button is small enough.
When laying out larger buttons you can use android:drawablePadding
in conjunction with android:paddingLeft
and android:paddingRight
to force the text and drawable inward towards the center of the button. By adjusting the left and right padding separately you can make very detailed adjustments to the layout.
Here's an example button that uses padding to push the text and icon closer together than they would be by default:
<Button android:text="@string/button_label"
android:id="@+id/buttonId"
android:layout_width="160dip"
android:layout_height="60dip"
android:layout_gravity="center"
android:textSize="13dip"
android:drawableLeft="@drawable/button_icon"
android:drawablePadding="2dip"
android:paddingLeft="30dip"
android:paddingRight="26dip"
android:singleLine="true"
android:gravity="center" />