Abhinav Raja
Abhinav Raja

Reputation: 351

how to bring text close to image in a button

I have a button with an image and a text to left of it. When I apply them normally there is no space between the image and text but when i set the background to transparent there appears a small gap between the image and text. like this

http://postimg.org/image/hyhzhcyrx/cdcbe297/

and with transparent background it looks like

http://postimg.org/image/tf9joeuxn/077f7816/

i want to set transparent background but i don't want the space between the image and the text? how to do it? my button code is :

 <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="1" 
android:textSize="20sp"
android:textStyle="bold"

android:drawableLeft="@drawable/tick3"
/>

Upvotes: 0

Views: 125

Answers (1)

Yogesh Lakhotia
Yogesh Lakhotia

Reputation: 888

You need to set android:drawablePadding in negative to remove space between image and text

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="1" 
android:textSize="20sp"
android:textStyle="bold"
android:drawablePadding="-5sp"
android:drawableLeft="@drawable/tick3"
/>

Upvotes: 1

Related Questions