Reputation: 41
I want to put an image(Drawable) into a button. But the opcions are drawableLeft/Bottom/Top/Rigth. I want to put it in center. Background dont work because it stretched my image. The image is an drawable into drawable folder. If it possible the code in xml. Thanks!
The drawable:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/im_perfil"
android:bottom="20dp"
android:left="20dp"
android:right="20dp"
android:top="20dp"/>
</layer-list>
"im_perfil" is an ImageAsset,
I CAN! I use src!
Upvotes: 0
Views: 6141
Reputation: 179
Try putting drawable in image button using src like this
<ImageButton
android:id="@+id/btn_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@null"
android:src="@drawable/im_perfil" />
Upvotes: 6