Android parallax effect CollapsingToolbarLayout with ViewGroup Layout is not working
<p>I am developing an Android app. In my app, I am using CollapsingToolbarLayout for parallax effect. Before I used AppbarLayout, CollapsingToolbarLayout together with ViewPager, I was working fine. But this time, I replaced view holder for content with RelativeLayout. So when I scroll up from the content, toolbar is not collapsed. I mean when I scroll up from the position I circled in the screenshot below.</p>

<p><a href="https://i.stack.imgur.com/8BFhs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8BFhs.png" alt="enter image description here"></a></p>

<p>But if I scroll up from the toolbar area, it is working. I mean the area in the screenshot.</p>

<p><a href="https://i.stack.imgur.com/E35tD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E35tD.png" alt="enter image description here"></a></p>

<p>This is my XML layout</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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/background_light"
    android:fitsSystemWindows="true"
    &gt;

    &lt;android.support.design.widget.AppBarLayout
        android:id="@+id/ai_app_bar"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true"
        &gt;

        &lt;android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/main.collapsing"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginEnd="64dp"
            &gt;

           &lt;RelativeLayout
               android:background="@drawable/item"
               app:layout_collapseMode="parallax"
               android:layout_width="match_parent"
               android:layout_height="match_parent"&gt;
              &lt;View
                  android:background="@color/lightGray"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"&gt;&lt;/View&gt;
           &lt;/RelativeLayout&gt;

            &lt;android.support.v7.widget.Toolbar
                android:id="@+id/ai_toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin"
                /&gt;
        &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
    &lt;/android.support.design.widget.AppBarLayout&gt;


    &lt;RelativeLayout
        app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent"&gt;
        &lt;TextView
            android:text="This is testing"
            android:textColor="@color/textColorPrimary"
            android:layout_centerInParent="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" /&gt;
    &lt;/RelativeLayout&gt;

    &lt;android.support.design.widget.FloatingActionButton
        android:id="@+id/ai_review_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:src="@android:drawable/btn_star"
        android:layout_margin="10dp"
        android:visibility="gone"
        app:layout_anchor="@id/ai_app_bar"
        app:layout_anchorGravity="bottom|right|end"
        /&gt;
&lt;/android.support.design.widget.CoordinatorLayout&gt;
</code></pre>

<p>Why toolbar is not collapsed when I scroll up from the relative layout area? How can I fix that to be the toolbar collapsed if I scroll up from the RelativeLayout area?</p>