Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button with image and text centered [duplicate]

I need button with text in the middle and icon left of text.

my button :

<Button
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:onClick=""
            android:text="@string/search_button"
            android:textColor="@drawable/button_text"
            android:layout_weight="1"
            android:background="@drawable/button"
            android:drawableLeft="@drawable/new_star_nonactive" />

I need button with width fill_parent (all screen width)

but I have this : enter image description here

How can I set image position center, near the text?

like image 836
yital9 Avatar asked Jul 06 '12 12:07

yital9


1 Answers

Then only way to do that, is to use padding. In your case you want the image to move to the right, so use android:paddingLeft="50dp" or the amount of dips you want to move.

EDIT: also add android:gravity="left | center" in order to get the text right with the image.

like image 166
Carnal Avatar answered Sep 30 '22 00:09

Carnal