Android: image view button inside

I need to be able to display a button in my layout, but I want the button to have an image (a small icon) and text inside it.

something like this: ___________________ / *** SOME TEXT / /_**_______________/ 

where * s is the image

So I thought it would make a linear layout with a background and make it clickable - which would probably work, but that means it won't behave exactly like a button ...

Do you have a better idea on how to do this?

Thank you, e.

+7
source share
1 answer

In your xml layout for the button add:

 <Button ... android:drawableLeft="@drawable/myIcon" android:drawablePadding="5dp" android:paddingLeft="10dp" android:text="My text" /> 

Where myIcon.png is your icon in the folder with the ability to transfer.

EDIT Gasket added. EDIT 2: Added padding to the left of the icon.

+17
source

All Articles