henrytao-me / smooth-app-bar-layout

Smooth version of Google Support Design AppBarLayout
Apache License 2.0
1.77k stars 240 forks source link

Problem with using RecyclerView in NestedScrollView #180

Closed handjiny closed 7 years ago

handjiny commented 7 years ago

When I use RecyclerView in NestedScrollView, I do not smooth the RecyclerView part.

How do I do it?

henrytao-me commented 7 years ago

Hi @handjiny

Please post your layout here? I would like to take a look. Thanks.

handjiny commented 7 years ago

Thank you for your comment

<?xml version="1.0" encoding="utf-8"?>
<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.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorAccent"
            android:paddingTop="@dimen/app_bar_height">
            <RelativeLayout
                android:id="@+id/title_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:padding="@dimen/activity_horizontal_margin"
                android:background="@color/contents_danger">

                <TextView
                    android:id="@+id/tv_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="40dp"
                    android:textSize="@dimen/_20sp"
                    android:text="title"
                    android:layout_alignParentTop="true"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true" />
            </RelativeLayout>
            <RelativeLayout
                android:id="@+id/contents_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/title_container"
                android:padding="@dimen/activity_horizontal_margin">
                <me.next.tagview.TagCloudView
                    android:id="@+id/tag_cloud_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tcvItemBorderHorizontal="8dp"
                    app:tcvItemBorderVertical="6dp"
                    app:tcvBorder="8dp"
                    app:tcvBackground="@color/background_tag_selector"
                    app:tcvTextColor="@color/colorAccent"
                    app:tcvSingleLine="false"
                    app:tcvCanTagClick="true" />
                <View
                    android:id="@+id/divider_below"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_below="@id/tag_cloud_view"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="15dp"
                    android:background="@color/tag_view_divider" />
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="1000dp"
                    android:layout_below="@id/divider_below"
                    android:textColor="@color/colorSub"
                    android:lineSpacingExtra="10dp"
                    android:text="content"/>
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/reply_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/colorMainBG"
                android:layout_below="@id/contents_container"
                android:padding="@dimen/activity_horizontal_margin">
                <TextView
                    android:id="@+id/reply_label"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/text_reply_label"
                    android:textSize="@dimen/_17sp"
                    android:text="label"/>
            </RelativeLayout>
            <android.support.v7.widget.RecyclerView
                android:id="@+id/rc_reply"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/reply_container"
                android:clipToPadding="false"/>
        </RelativeLayout>
    </android.support.v4.widget.NestedScrollView>

    <me.henrytao.smoothappbarlayout.SmoothAppBarLayout
        android:id="@+id/smooth_app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height">
        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="@color/colorSub">
            <ImageView
                android:id="@+id/iv_parallax_image"
                android:layout_width="match_parent"
                android:layout_height="256dp"
                android:src="@drawable/main_thum"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax" />
            <android.support.v7.widget.Toolbar
                android:id="@+id/tb_header_bar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="right"
                    android:layout_marginRight="15dp">
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/bookmark_off"/>
                </RelativeLayout>
            </android.support.v7.widget.Toolbar>
        </android.support.design.widget.CollapsingToolbarLayout>
    </me.henrytao.smoothappbarlayout.SmoothAppBarLayout>
</android.support.design.widget.CoordinatorLayout>

RecyclerView area is not smooth

henrytao-me commented 7 years ago

Hi @handjiny

There is simple fix for it. Try this

vRecyclerView.setNestedScrollingEnabled(false);

Let me know if it works for you.

handjiny commented 7 years ago

Wow thanks.!!! very well.

henrytao-me commented 7 years ago

You are welcome. I will close this ticket for now. Happy coding!

pathak2308 commented 6 years ago

I am also facing the same issue, i am not able to scroll smoothly inside recycler view using nested scroll view. please help me out

FatehAliAsamadi commented 6 years ago

Send me your layout file So I can help you!

aungtuntun commented 6 years ago

Thanks, you save my time!!! it works very well, @henrytao-me .

sindhuraksha23 commented 6 years ago

I'm also facing the same issue and the fix: vRecyclerView.setNestedScrollingEnabled(false); didn't work for me.