Bartosz Ostrowski
Bartosz Ostrowski

Reputation: 431

Distance between icon and text in the Button

I have a button defined in the XML shown below:

<Button
    android:layout_width="@dimen/logo_menu_width"
    android:layout_height="@dimen/logo_menu_height"
    android:layout_margin="@dimen/logo_menu_margins"
    android:gravity="left|center_vertical"
    android:background="@drawable/selector_blue"
    android:drawableStart="@drawable/ic_action_settings"
    android:paddingStart="6dp"
    android:text="Options"
    android:textColor="@color/blue_light"
    android:textSize="@dimen/logo_menu_text"
    android:id="@+id/buttonOptions"
    android:layout_gravity="center_horizontal" />

How to increase distance between icon (set with drawableStart) and text? Text alignment is set to left. paddingStart is set to 6dp, but it applies to icon only, not the text.

Is it possible to set it with XML file?

I know I can do this using LinearLayout - containing both ImageView and TextView, but I am trying to limit nesting of the views.

Upvotes: 8

Views: 5241

Answers (2)

Ashwin
Ashwin

Reputation: 509

app:iconPadding is used to determine the space between icon and text in MaterialButton

Upvotes: 4

Karakuri
Karakuri

Reputation: 38605

Use the android:drawablePadding attribute.

Upvotes: 21

Related Questions