Why TabLayout is overlapping toolbar?
<p>I am trying to auto hide toolbar, for this i have switched to <code>coordinatelayout</code>, but due to some reason, toolbar gets into half, like tabslayout overlaps it. i have tried making toolbar height <code>wrap_content</code> but this leads to another problem, that whenever i click on something in activity, toolbar overlaps that much of activity above the clicked item.</p>

<p>Here is my Main activity:</p>

<pre><code>&lt;android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true"&gt;

&lt;android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    &gt;
&lt;android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tool_bar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:elevation="2dp"
    android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways"
    android:fitsSystemWindows="true"
    /&gt;

    &lt;android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:scrollbars="horizontal"
        android:layout_below="@+id/tool_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        app:tabTextColor="@android:color/white"
        app:tabSelectedTextColor="@android:color/white"
        app:tabIndicatorColor="@android:color/white"
        app:tabIndicatorHeight="3dp" /&gt;

&lt;/android.support.design.widget.AppBarLayout&gt;

&lt;android.support.v4.view.ViewPager
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:layout_below="@+id/tabs"&gt;
&lt;/android.support.v4.view.ViewPager&gt;
</code></pre>

<p></p>