How to use RecyclerView with NestedScrollView?

Viewed 2673

I want to make a scrolling at LinearLayout and disable scrolling from RecyclerView. I tried changing LinearLayout to NestedScrollView but it doesn't work and i don't know why.

I've tried this question but it doesn't work well. The content in RecyclerView can be loaded dynamically from WS and it's an endless scroll. The screen was freezing when content in RecyclerView updated.

I've seen this from Twitter, how can we do this https://drive.google.com/file/d/0B2JZggeoXKKFdG1ENmZEdWFIa0k/view?usp=sharing

Example
This is my simple screen of my app, i want scrolling at red currently, and it currently scrolls at 'blue'. Many thanks.

enter image description here

Code

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

<ImageView
    android:layout_width="match_parent"
    android:layout_height="160dp"
    android:layout_margin="16dp"
    android:background="#CCC"
    android:id="@+id/imageView2" />

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Image caption"
    android:background="#cbffa3"
    android:padding="16dp"
    android:id="@+id/textView8" />

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

</LinearLayout>

Tried but not work, contents inside RecyclerView not showing

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="160dp"
            android:layout_margin="16dp"
            android:background="#CCC"
            android:id="@+id/imageView2" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Image caption"
            android:background="#cbffa3"
            android:padding="16dp"
            android:id="@+id/textView8" />

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

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>
2 Answers
Related