0

Followed this link Overlap scrolling view with AppBarLayout but overlapping doesn't seems to work well.Here i'm attaching my layout files with the output that i got.

activity_main.xml

<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.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="192dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|enterAlways">

            <android.support.v7.widget.Toolbar
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:behavior_overlapTop="64dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:elevation="5dp"
        >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/days_list_5"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            </android.support.v7.widget.RecyclerView>

        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

custom_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:orientation="vertical">

    <android.support.v7.widget.CardView
        android:id="@+id/cardNews"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:background="@color/colorAccent"
        android:layout_margin="16dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/lblNewsTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"

                android:textColor="@color/colorAccent"
                android:textSize="16dp" />
        </LinearLayout>

    </android.support.v7.widget.CardView>

</LinearLayout>

enter image description here

Please have a look and give me your suggestion where i'm wrong.

Community
  • 1
  • 1
Pranesh Sahu
  • 595
  • 5
  • 26
  • 1
    Try to set `app:layout_scrollFlags="scroll|exitUntilCollapsed">` in your `CollapsingToolbarLayout` – beeb Mar 20 '17 at 15:02

1 Answers1

0

By removing android:background="@android:color/white" from my custom layout and changing the CollapsingToolBar as app:layout_scrollFlags="scroll|enterAlwaysCollapsed",I resolved the issue.

Pranesh Sahu
  • 595
  • 5
  • 26