David
David

Reputation: 414

Align icon at text left in a Button

How I can align the icon at text left? If I put drawableStart it appears at the center-top of the button.

enter image description here

Upvotes: 0

Views: 74

Answers (1)

niks
niks

Reputation: 173

The center_vertical will align your text to center and if your drawable has invisible padding please check. Also, check if the background resource has any padding. Otherwise below code will work fine.

<Button
    android:layout_width="200dp" 
    android:layout_height="80dp"
    android:drawableStart="@android:drawable/ic_dialog_info"
    android:text="@string/app_name"
    android:gravity="start|center_vertical"
    android:drawablePadding="10dp" // padding in between icon and text
    android:paddingStart="40dp" // start padding for icon
    />

Upvotes: 1

Related Questions