I am having Recyclerview inside Scrollview
<Scrollview
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="@+id/layoutStaticContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
//Static content.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp">
.
.
<LinearLayout>
//Dynamic content(newsfeed)
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
Now while scrolling, layoutStaticContent stays fix on the top & recyclerview content scrolls independently in the bottom part. How to scroll the whole content i.e (layoutStaticContent + recyclerview content) such that there is only 1 scrollview? I also tried replacing scrollview with Nestedscrollview but no success.
Put the LinearLayout which contains both the static and dynamic data inside of a NestedScrollView and it'll work like a charm.
Here is the code you need:
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/layoutStaticContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
//Static content.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp">
.
.
<LinearLayout>
//Dynamic content(newsfeed)
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
I hope it helps!
Use the android.support.v4.widget.NestedScrollView
then inside both layout
NestedScrollView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With