RecyclerView inside NestedScrollView, is it possible?

Posted: February 16, 2016 in Android, Technology
Tags: , , , ,

Hello all,

After getting so many +1 over stackoverflow for my answer on the question : How to use RecyclerView inside NestedScrollView?

You can add RecyclerView without adding it into NestedScrollView. How? Here is the trick:

<android.support.design.widget.CoordinatorLayout
 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:layout_width="match_parent"
 android:layout_height="match_parent" android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
 android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">

 <android.support.v7.widget.Toolbar
 android:layout_width="match_parent"
 android:layout_height="?attr/actionBarSize"
 android:background="?attr/colorPrimary"
 app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
 app:layout_behavior="@string/appbar_scrolling_view_behavior"
 android:layout_width="match_parent"
 android:layout_height="wrap_content" />
</android.support.design.widget.CoordinatorLayout>

The key thing here is :

 app:layout_behavior="@string/appbar_scrolling_view_behavior" 

Have fun! Keep Coding!

Advertisements
Comments
  1. Short and Effective solution… (y)..

  2. andro-girl says:

    Hi I ahve 2 recyclerviews inside nested scrollview. i have added the property app:layout_behavior=”@string/appbar_scrolling_view_behavior” . but the recyclerviews drawing its children at one shot. how can i prevent this?

  3. this is not working for me.
    Please check my xml below :

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s