1

I use android.support.v7.widget.Toolbar in my app.

I can set icon by getSupportActionBar().setIcon(). And set title text by toolbar.setTitle().

But distance between icon and title is 0 as on pic: enter image description here

How I can change distance between icon and title programatically (without custom ImageView and TextView inside Toolbar)?

Tapa Save
  • 4,769
  • 5
  • 32
  • 54

1 Answers1

3

A simple solution is adding app:titleMarginStart in the xml Toolbar declaration

Here is an example:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:popupTheme="@style/AppTheme.PopupOverlay"
    app:titleMarginStart="32dp"/>
Rafael Lucena
  • 635
  • 1
  • 6
  • 9