4

Does anyone know how to reduce the padding between de navigation icon and logo on a toolbar. for some reason it seems like there is way more space between them then between my logo and title.

I've already tried to add a style and use contentInset but none of them seem to work.

My layout

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/background_grey"
android:style="@style/ToolbarTheme"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"
app:logo="@drawable/ic_launcher">

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

My style

<style name="ToolbarTheme" parent="Theme.AppCompat">
    <item name="android:minWidth">0dip</item>
    <item name="android:paddingLeft">0dip</item>
    <item name="android:paddingRight">0dip</item>
</style>

Image (Space indicated by red lines should be smaller)

Jason Lie
  • 159
  • 3
  • 12
  • Can you post the screenshot of the Toolbar with the navigation icon and logo in which you are facing the issue. – Karthik Oct 21 '15 at 16:41
  • @Karthik I've added a image – Jason Lie Oct 22 '15 at 08:29
  • Possible duplicate of [How to reduce the gap between navigation icon and toolbar title?](http://stackoverflow.com/questions/40717684/how-to-reduce-the-gap-between-navigation-icon-and-toolbar-title) – computingfreak Mar 09 '17 at 07:59

2 Answers2

16

If you are interested only in Reducing padding between navigation icon and logo on my toolbar, use Toolbar.setContentInsetStartWithNavigation(0)

Unlike contentInsetStart, this will modify the inset only when there is a Navigation Icon. In the absence of the Navigation Icon, you will still have the 16dp start inset.

pRaNaY
  • 24,642
  • 24
  • 96
  • 146
Henry
  • 17,490
  • 7
  • 63
  • 98
0

Just add app:contentInsetStart="0dp" in your toolbar xml.

Before adding app:contentInsetStart="0dp" Output is:

enter image description here

After adding app:contentInsetStart="0dp" Output is:

enter image description here Hope its help. Done

pRaNaY
  • 24,642
  • 24
  • 96
  • 146
  • 1
    I have used the same `app:contentInsetStart="0dp` inside my `Toolbar` but it is not working.Please help me on it – Ravindra Kushwaha Aug 11 '17 at 07:56
  • @RavindraKushwaha did you solved it? I too have the same issue and setting contentInsetStart to 0dp is not helping. – Rahul Nov 24 '17 at 07:57
  • @Rahul Please refer this link , it can be helpful for you https://stackoverflow.com/a/45628064/3946958 – Ravindra Kushwaha Nov 29 '17 at 05:50
  • @Ravindra Kushwaha, in my case the target layout was placed in a container that still had its own padding, so the setting had no effect. – kirkadev Sep 15 '21 at 07:02