Android Coordinator layout problems
<p>I am using coordinator layout with a custom collapsing view and tablayout.
Here is the xml </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"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="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:theme="@style/ThemeOverlay.AppCompat.Light"&gt;

    &lt;android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;

        &lt;RelativeLayout
            android:id="@+id/cardParentLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_collapseMode="parallax"&gt;

            &lt;com.facebook.drawee.view.SimpleDraweeView
                android:id="@+id/profilePicOverlay"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                fresco:actualImageScaleType="centerCrop"
                fresco:overlayImage="@drawable/profile_overlay" /&gt;

            &lt;RelativeLayout
                android:id="@+id/childParentToAnimate"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="invisible"&gt;

                &lt;include
                    android:id="@+id/cardLayout"
                    layout="@layout/layout_profile_card"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true" /&gt;

                &lt;com.facebook.drawee.view.SimpleDraweeView
                    android:id="@+id/profilePicCard"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    fresco:actualImageScaleType="centerCrop"
                    fresco:backgroundImage="@drawable/profile_placeholder"
                    fresco:roundAsCircle="true"
                    fresco:roundingBorderColor="@color/white"
                    fresco:roundingBorderWidth="2dp" /&gt;

            &lt;/RelativeLayout&gt;

        &lt;/RelativeLayout&gt;

        &lt;android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="51dp"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/AppTheme" /&gt;

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

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

&lt;LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="fill_vertical"
    android:fillViewport="true"
    android:orientation="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;

    &lt;android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_gravity="bottom"
        android:background="@color/blue_primary"
        app:tabGravity="fill"
        app:tabIndicatorColor="@android:color/white"
        app:tabMode="fixed" /&gt;

    &lt;android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" /&gt;

&lt;/LinearLayout&gt;

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

<p>The problem is that when collapsed, the toolbar is appearing white (default gray color) as you can see in this image.</p>

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

<p>If I add background attribute to toolbar in xml, the toolbar is appearing even when not collapsed</p>