Keep image next to text inside a button

2

Maybe it's a simple situation, but I've already broken my head here and still have not succeeded.

I have a button, and inside it I load an image and a text.

<Button
    android:id="@+id/btNovaPreVenda"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="16dp"
    android:background="@drawable/shape"
    android:drawableLeft="@drawable/carrinhodecompras"
    android:paddingTop="1sp"
    android:text=" | Nova Pré-Venda"    
    android:textColor="@color/branco" />

However, because layout_width is set to fill_parent , the image is left and text is centered. However, if I put the layout_width as wrap_content, it works because the button will be created as needed.

Any idea how to leave layout_width as fill_parent and the image be centered with the text?

Currently, this is . I would like to like

    
asked by anonymous 27.06.2014 / 15:33

2 answers

1

Try to put:

    android:paddingLeft="100dp"
    android:drawablePadding="-60dp"

I just tested here and it worked !!!

I hope I have helped!

    
27.06.2014 / 16:13
1

Have you tried to place% android:drawableRight=
 instead of android:drawableleft=

or places android:drawableleft= with padding greater. In the shopping cart for example.

    
27.06.2014 / 16:07