Parallax effect not working in RelativeLayout with CoordinateLayout android
<p>I have a <code>relativelayout</code> that needs to give <code>parallax effect</code> . I am using <code>CoordinateLayout</code> for this.</p>

<p>I <code>relativelayout</code> is not giving me the <code>parallax effect</code>. I used NestedScrollView for scrolling.</p>

<p><strong>What the layout file contains</strong></p>

<p>1 CoordinatorLayout</p>

<p>1 DrawerLayout</p>

<p>1 AppBarLayout</p>

<p>2 Toolbar</p>

<p>1 ViewPager</p>

<p>my code :</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;android.support.v4.widget.DrawerLayout 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/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"&gt;

    &lt;android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"&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.Dark.ActionBar"&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:expandedTitleMarginEnd="64dp"
                app:expandedTitleMarginStart="48dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;


                &lt;LinearLayout
                    android:id="@+id/linear_profile"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"&gt;


                    &lt;android.support.v7.widget.Toolbar
                        android:id="@+id/toolbar_home"
                        android:layout_width="match_parent"
                        android:layout_height="56dp"
                        android:background="@color/cyan_dark"
                        android:visibility="visible"
                        app:contentInsetEnd="0dp"
                        app:contentInsetStart="0dp"
                        app:layout_collapseMode="pin"&gt;

                        &lt;ImageView
                            android:id="@+id/img_back"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentLeft="true"
                            android:paddingBottom="10dp"
                            android:paddingLeft="10dp"
                            android:paddingRight="30dp"
                            android:paddingTop="10dp"
                            android:src="@drawable/ic_back"
                            android:visibility="visible" /&gt;


                        &lt;RelativeLayout
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"&gt;

                            &lt;TextView
                                android:id="@+id/tv_header_tittle"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_centerHorizontal="true"
                                android:layout_centerInParent="true"
                                android:maxLength="50"
                                android:padding="5dp"
                                android:text="Change Password"
                                android:textColor="@color/white"
                                android:textSize="@dimen/txt_large" /&gt;

                            &lt;com.viewpagerindicator.CirclePageIndicator
                                android:id="@+id/circle_indicator"
                                android:layout_width="100dp"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/tv_header_tittle"
                                android:layout_centerHorizontal="true"
                                android:layout_gravity="center"
                                android:layout_marginBottom="2dp"
                                android:layout_marginTop="2dp"
                                android:visibility="visible"
                                app:fillColor="@color/white"
                                app:pageColor="@color/cyan_dark"
                                app:strokeColor="@color/white" /&gt;
                        &lt;/RelativeLayout&gt;


                        &lt;ImageView
                            android:id="@+id/img_glob"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="right"
                            android:paddingBottom="10dp"
                            android:paddingLeft="30dp"
                            android:paddingRight="10dp"
                            android:paddingTop="10dp"
                            android:src="@drawable/ic_home_globe"
                            android:visibility="visible" /&gt;

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

                    &lt;RelativeLayout
                        android:id="@+id/relative_profile_hotot"
                        android:layout_width="match_parent"
                        android:layout_height="250dp"
                        android:padding="0dp"
                        app:layout_collapseMode="parallax"
                        android:visibility="visible"&gt;

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


                            &lt;com.android.volley.toolbox.NetworkImageView
                                android:id="@+id/img_profile_cover"
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:scaleType="centerCrop"
                                android:src="@drawable/im_default_cover" /&gt;

                            &lt;ImageView
                                android:id="@+id/img_edit_cover"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentRight="true"
                                android:layout_alignParentTop="true"
                                android:padding="20dp"
                                android:scaleType="fitXY"
                                android:src="@drawable/btn_profile_edit" /&gt;


                            &lt;android.support.v7.widget.Toolbar
                                android:id="@+id/relative_profile_footer"
                                android:layout_width="match_parent"
                                android:layout_height="40dp"
                                android:layout_alignParentBottom="true"
                                android:background="@color/album_name_bg"&gt;

                                &lt;TextView
                                    android:id="@+id/tv_profile_name"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="left"
                                    android:paddingLeft="5dp"
                                    android:paddingTop="5dp"
                                    android:textColor="@color/white"
                                    android:textSize="@dimen/txt_small"
                                    tools:text="Karan Asrani" /&gt;

                                &lt;TextView
                                    android:id="@+id/tv_profile_location"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:drawableLeft="@drawable/ic_home_place"
                                    android:drawablePadding="5dp"
                                    android:drawableRight="@drawable/btn_profile_edit"
                                    android:paddingRight="5dp"
                                    android:paddingTop="5dp"
                                    android:textColor="@color/white"
                                    android:textSize="@dimen/txt_small"
                                    tools:text="Paris France" /&gt;


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


                            &lt;RelativeLayout
                                android:id="@+id/relative_profile_pic"
                                android:layout_width="70dp"
                                android:layout_height="70dp"
                                android:layout_alignParentBottom="true"
                                android:layout_centerHorizontal="true"
                                android:layout_marginBottom="30dp"&gt;

                                &lt;camera.CircledNetworkImageView
                                    android:id="@+id/img_profile_pic"
                                    android:layout_width="match_parent"
                                    android:layout_height="match_parent"
                                    android:src="@drawable/im_home_profile_default"
                                    app:layout_anchor="@id/appbar" /&gt;


                                &lt;ImageView
                                    android:id="@+id/img_edit_profile"
                                    android:layout_width="15dp"
                                    android:layout_height="15dp"
                                    android:layout_alignBottom="@+id/img_profile_pic"
                                    android:layout_alignEnd="@+id/img_profile_pic"
                                    android:layout_alignRight="@+id/img_profile_pic"
                                    android:layout_marginBottom="10dp"
                                    android:layout_marginRight="3dp"
                                    android:src="@drawable/btn_profile_edit"
                                    android:visibility="visible" /&gt;


                                &lt;ImageView
                                    android:id="@+id/img_profile_pic_status"
                                    android:layout_width="18dp"
                                    android:layout_height="18dp"
                                    android:layout_alignParentBottom="true"
                                    android:layout_alignParentRight="true"
                                    android:layout_marginBottom="2dp"
                                    android:layout_marginRight="5dp"
                                    android:src="@drawable/ic_home_red_circle"
                                    android:visibility="gone" /&gt;


                            &lt;/RelativeLayout&gt;


                        &lt;/RelativeLayout&gt;


                        &lt;ProgressBar
                            android:id="@+id/prg_dialog"
                            android:layout_width="60dp"
                            android:layout_height="60dp"
                            android:layout_centerInParent="true"
                            android:visibility="gone" /&gt;

                        &lt;TextView
                            android:id="@+id/txt_loading"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/prg_dialog"
                            android:layout_centerHorizontal="true"
                            android:textColor="@color/text_color"
                            android:textSize="@dimen/txt_large"
                            android:visibility="gone" /&gt;
                    &lt;/RelativeLayout&gt;
                &lt;/LinearLayout&gt;

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

        &lt;android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;

            &lt;LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"&gt;

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

            &lt;/LinearLayout&gt;


        &lt;/android.support.v4.widget.NestedScrollView&gt;

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


    &lt;android.support.v7.widget.RecyclerView
        android:id="@+id/rv_navigation"
        android:layout_width="250dp"
        android:layout_height="match_parent"
        android:layout_below="@+id/bucket_header"
        android:layout_gravity="end"
        android:background="@drawable/splashscreen_bg"
        android:descendantFocusability="afterDescendants"
        android:focusable="false"
        android:visibility="visible"&gt;&lt;/android.support.v7.widget.RecyclerView&gt;
&lt;/android.support.v4.widget.DrawerLayout&gt;
</code></pre>