Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView inside SwipeRefreshLayout inside NestedScrollViewLayout cannot scroll

I have an activity with collapsing toolbar and a nested scroll view with a FrameLayout that I place the fragments in it. Initially, I place in it a FragmentA with a CardView .

Works great. When I click a button though I replace that FragmentB with another one containing a RecyclerView .

When I add the FragmentB I cant scroll to the bottom of the list.

Host Activity Layout:

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="340dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true">


    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlwaysCollapsed"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp">

        .........
          ......
    </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"
    android:layout_gravity="fill_vertical"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    >

    <!-- the layout which will be the content of the activity (which will be hosted inside the drawer (NOT the list of the drawer)) -->
    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >

    </FrameLayout>

</android.support.v4.widget.NestedScrollView>

FragmentB Layout:

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/contentView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">


    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_users"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"

        android:layout_height="wrap_content" />

    <include
        layout="@layout/view_progress"
        />

    <include
        layout="@layout/view_retry"
        />

    <!--</LinearLayout>-->

</android.support.v4.widget.SwipeRefreshLayout>
like image 463
Manos Avatar asked Jun 22 '16 10:06

Manos


1 Answers

You put RecyclerView inside the NestedScrollView.
I think better solution is to have NestedScrollView or RecyclerView but not both, because RecyclerView is already implementing NestedScrollingChild.

I have similar layout in my app. I did the same - put RecyclerView to FrameLayout and then inside the NestedScrollView. It's stop to work correctly. Without NestedScrollView everything works fine.

like image 200
thealeksandr Avatar answered Oct 05 '22 01:10

thealeksandr