29

Here is a picture of the large padding gap after the menu icon: enter image description here

This occurred after not working on my project for a month (summer school). I just came back to it and noticed this larger than normal gap on the toolbar after I updated Android Studio. I can't find any questions/solutions about this on SO. If anyone can help that would be very much appreciated.

I am loading the hamburger icon by doing this (each line is properly placed in the app, in either the class declaration, onCreate(), etc. I put it like this for simplicity.):

ActionBarDrawerToggle mDrawerToggle;
mDrawerToggle = new ActionBarDrawerToggle(getActivity(), dl, toolbar, R.string.nav_open, R.string.nav_closed)
mDrawerToggle.syncState();

Here is the xml code for my toolbar:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:minHeight="?attr/actionBarSize"
    app:layout_scrollFlags="scroll|enterAlways"
    app:title="Test Title">

</android.support.v7.widget.Toolbar>

I tried messing around with the various contentInset xml attributes but none affected the spacing after the menu icon.

EDIT: This link shows what I used to have (found around the middle of the page). If you notice the spacing between the title and the hamburger icon, the spacing is not as wide as in the picture shown here. It's as if the spacing got doubled or something.

David Velasquez
  • 2,346
  • 1
  • 26
  • 46
  • possible duplicate of [padding-between-actionbars-home-icon-and-title](http://stackoverflow.com/questions/9737101/padding-between-actionbars-home-icon-and-title) – Mohamad Damba Putrabangga Jul 14 '16 at 12:16
  • Additional note to both of the answers below: as they say, it should be put in the toolbar layout. I tried putting it in themes, but it is not working set as theme of the toolbar layout. – vida Jun 22 '17 at 02:13

2 Answers2

62

I figured it out! I had to set

app:contentInsetStartWithNavigation="0dp"

in my Toolbar layout.

enter image description here

David Velasquez
  • 2,346
  • 1
  • 26
  • 46
16

Add these properties to your Toolbar:

app:contentInsetLeft="0dp" 
app:contentInsetStart="0dp" 
app:contentInsetStartWithNavigation="0dp"

This will disable inset start padding from Toolbar's title

blueware
  • 5,205
  • 1
  • 40
  • 60