Keep image next to text inside a button

Asked

Viewed 5,630 times

2

Maybe it’s a simple situation, but I’ve already cracked my head a little bit here and I haven’t succeeded yet.

I have a button, and inside it I upload an image and 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" />

Only that by layout_width be set as fill_parent, the image is on the left and the text is centered. However, if I put layout_width as wrap_content, it works because the button will be created of the required size.

Any idea how to leave the layout_width as fill_parent and the image is centered on the text?

Currently, is thus. I’d like to leave thus

  • has how to take a print to view better

  • @Rogerscorrêa - Add the print. Thanks!

  • and I’ll tell you that aesthetically the way it is is much more beautiful than the one you want to put... : P As you want to do, it gets a little disorganized passes the impression of mess the menu.(Sincerity). I think it’s best to keep it as it is.

  • I tbm think that the way it is (aligned to the left) is good. But they did not approve. They want to join the text. kkk

2 answers

1

Ever tried to put
android:drawableRight=
instead of
android:drawableleft=

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

  • It worked. Had not used android:paddingleft. Thanks.

1


Try to put:

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

I just tested here and it worked!!!

I hope I’ve helped!

  • Thank you so much for your help. It worked out. the/

  • Dinada! I am available, we are here for this!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.