How to remove top and bottom padding from android.support.v7.widget.Toolbar?

Viewed 4745

I am trying to place a SlidingTabLayout inside my android.support.v7.widget.Toolbar but for some reason there is extra top and bottom padding in portrait layout. As shown in this screenshot:

Portrait

In landscape layout the android.support.v7.widget.Toolbar is shorter and the extra padding is gone:

Landscape

I am aware of the contentInsertStart and contentInsetEnd attributes but there does not appear to be anything for top and bottom. Here is my layout:

<android.support.design.widget.AppBarLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:theme="?attr/actionBarTheme"
    >

    <!-- Changing the size of the toolbar fixed the problem below but I don't like the solution since the height difference is perceptible -->
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?attr/colorPrimary"
        android:padding="0dp"
        app:popupTheme="?attr/actionBarPopupTheme"
        >

        <!-- TODO: BUG - This isn't filling out the action bar in portrait (see note above) -->
        <com.myapplication.views.widgets.SlidingTabLayout
            android:id="@+id/sliding_tabs"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@color/pink_400"
            />

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

</android.support.design.widget.AppBarLayout>

As indicated in the comments if I manually set the height of the android.support.v7.widget.Toolbar to 48dp then the SlidingTabLayout fills it out but there are two problems here:

  1. The toolbar is a different height than the standard toolbar which is noticeable when changing activities.
  2. The icons in the Toolbar are no longer vertically centered if I change it's height

So as the title says, how do I remove top and bottom padding from android.support.v7.widget.Toolbar?

1 Answers
Related