Fragment in ViewPager not triggering scroll on Coordinator Layout
<p>So, I have a MainActivity with a CoordinatorLayout to make that cool scroll effect on Android.
This is my <code>activity_main.xml</code></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.design.widget.CoordinatorLayout 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:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="br.com.alberson.apontadordehoras.MainActivity"&gt;

    &lt;android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/AppTheme.AppBarOverlay"&gt;

        &lt;android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay"&gt;

        &lt;/android.support.v7.widget.Toolbar&gt;

        &lt;android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" /&gt;

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

    &lt;android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" /&gt;

    &lt;android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" /&gt;

&lt;/android.support.design.widget.CoordinatorLayout&gt;
</code></pre>

<p>And this is my <code>fragment.xml</code></p>

<pre><code>&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    tools:context="br.com.alberson.apontadordehoras.MesFragment"&gt;

    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="@dimen/activity_vertical_margin"
        android:layout_marginEnd="@dimen/activity_horizontal_margin"
        android:layout_marginLeft="@dimen/activity_horizontal_margin"
        android:layout_marginRight="@dimen/activity_horizontal_margin"
        android:layout_marginStart="@dimen/activity_horizontal_margin"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:orientation="vertical"&gt;

        &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="@dimen/cardview_default_elevation"
            android:padding="@dimen/fab_margin"
            card_view:cardCornerRadius="@dimen/cardview_default_radius"&gt;

            &lt;LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/activity_vertical_margin"
                android:layout_marginEnd="@dimen/activity_horizontal_margin"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:layout_marginStart="@dimen/activity_horizontal_margin"
                android:layout_marginTop="@dimen/activity_vertical_margin"
                android:orientation="vertical"&gt;

                &lt;TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top|start"
                    android:text="@string/realizado" /&gt;

                &lt;TextView
                    android:id="@+id/mes_realizado"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginBottom="@dimen/activity_vertical_margin"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:gravity="center"
                    android:text="70 horas"
                    android:textSize="38sp"
                    android:textStyle="bold" /&gt;

                &lt;TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top|start"
                    android:text="@string/media_por_dia" /&gt;

                &lt;TextView
                    android:id="@+id/mes_media_por_dia"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginBottom="@dimen/activity_vertical_margin"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:gravity="center"
                    android:text="8,5 horas"
                    android:textSize="38sp"
                    android:textStyle="bold" /&gt;

                &lt;TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top|start"
                    android:text="@string/horas_dia_meta" /&gt;

                &lt;TextView
                    android:id="@+id/mes_horas_dia_para_meta"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginBottom="@dimen/activity_vertical_margin"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:gravity="center"
                    android:text="8,5 horas"
                    android:textSize="38sp"
                    android:textStyle="bold" /&gt;

                &lt;TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top|start"
                    android:text="@string/horas_dia_previsto" /&gt;

                &lt;TextView
                    android:id="@+id/mes_horas_dia_para_previsto"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginBottom="@dimen/activity_vertical_margin"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:gravity="center"
                    android:text="8,5 horas"
                    android:textSize="38sp"
                    android:textStyle="bold" /&gt;
            &lt;/LinearLayout&gt;
        &lt;/android.support.v7.widget.CardView&gt;

        &lt;android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/activity_vertical_margin"
            android:layout_marginTop="@dimen/activity_vertical_margin"
            android:elevation="@dimen/cardview_default_elevation"
            android:padding="@dimen/fab_margin"
            card_view:cardCornerRadius="@dimen/cardview_default_radius"&gt;

            &lt;android.support.v7.widget.GridLayout xmlns:grid="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="@dimen/activity_vertical_margin"
                android:layout_marginEnd="@dimen/activity_horizontal_margin"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:layout_marginStart="@dimen/activity_horizontal_margin"
                android:layout_marginTop="@dimen/activity_vertical_margin"
                grid:columnCount="2"&gt;

                &lt;LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="vertical"
                    grid:layout_columnWeight="1"
                    grid:layout_gravity="fill_horizontal"&gt;

                    &lt;TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:text="@string/meta_desejada" /&gt;

                    &lt;TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="200 horas"
                        android:textStyle="bold" /&gt;
                &lt;/LinearLayout&gt;

                &lt;LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="vertical"
                    grid:layout_columnWeight="1"
                    grid:layout_gravity="fill_horizontal"&gt;

                    &lt;TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:text="@string/meta_desejada" /&gt;

                    &lt;TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="200 horas"
                        android:textStyle="bold" /&gt;
                &lt;/LinearLayout&gt;

                &lt;LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:orientation="vertical"
                    grid:layout_columnSpan="2"
                    grid:layout_gravity="fill_horizontal"&gt;

                    &lt;TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:text="@string/dias_uteis_restantes" /&gt;

                    &lt;TextView
                        android:id="@+id/mes_dias_uteis_restantes"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginTop="@dimen/activity_vertical_margin"
                        android:text="5"
                        android:textStyle="bold" /&gt;

                &lt;/LinearLayout&gt;
            &lt;/android.support.v7.widget.GridLayout&gt;
        &lt;/android.support.v7.widget.CardView&gt;
    &lt;/LinearLayout&gt;
&lt;/ScrollView&gt;
</code></pre>

<p>In the pager, there are 2 pages, each with one fragment.</p>

<p>I have 2 problems:</p>

<p>1) The ScrollView inside this fragment is not even showing, and then not scrolling with CoordinatorLayout.</p>

<p>2) If I scroll the TabLayout up, the content is scrolled up and the toolbar becomes hidden, the behaviour I expected while scrolling the fragment in the ViewPager.</p>

<p>What am I doing wrong?</p>