问题
When we use RecyclerView
inside NestedScrollView
app stuck where we call notifyDatasetChanged or notify inserted , it is because of when we call notify it is calling all item at same time ("it called onBindViewHolder at same time") so is there any solution to solve this issue?
If I remove NestedScrollView
it work but we can't use multiple layout("example 2 RecyclerView
")
code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="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:background="@color/lightback"
android:id="@+id/main_layouta"
android:orientation="vertical"
tools:ignore="NamespaceTypo">
<include layout="@layout/toolbar_social" />
<android.support.v4.widget.NestedScrollView
android:id="@+id/nestedview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.widget.NestedScrollView>
<android.support.v4.widget.NestedScrollView
android:fillViewport="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/below_toolbar_header_layout"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyc_social_stories"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="5dp"
android:nestedScrollingEnabled="false"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:paddingBottom="5dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyc_social_post"
android:layout_width="match_parent"
android:visibility="gone"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:nestedScrollingEnabled="false" />
<ProgressBar
android:layout_width="match_parent"
android:id="@+id/progress_bar"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="20dp" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
来源:https://stackoverflow.com/questions/54156630/nestedscrollview-issue-with-recyclerview