I have two Recyclerview inside NestedScrollView. The second Recyclerview also have SwipeRefreshLayout. I try to set one scroll for both recycler, but my solution didn't work. Two recycler scroll separately and I don't have solution, please help my. Thanks in advance. My code
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/noFriendsTitle"
android:layout_marginTop="@dimen/marginTop"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:text="@string/no_friends_title"/>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBarGetFriends"
android:layout_centerInParent="true"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainFriendsRelative"
android:paddingTop="@dimen/marginTopSmall"
android:paddingBottom="@dimen/marginTopSmall"
android:visibility="invisible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/paddingStart"
android:id="@+id/lastConversationTitle"
android:text="@string/friends_important_title"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lastChatFriendsRecyclerView"
android:layout_below="@+id/lastConversationTitle"
android:layout_marginTop="@dimen/marginTopSmall"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/paddingStart"
android:layout_below="@+id/lastChatFriendsRecyclerView"
android:layout_marginTop="@dimen/marginTopSmall"
android:id="@+id/allFriendsTitle"
android:text="@string/friends_all"/>
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/friendSwipeToRefresh"
android:layout_below="@+id/allFriendsTitle"
android:layout_marginTop="@dimen/marginTopSmall">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/friendsRecyclerView"
android:scrollbars="vertical"/>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</RelativeLayout>
My fragment code
private void setLastConversationFriendsRecycler(RecyclerView lastConversationRecyclerView, List<Edge<Friends>> friends){
lastConversationList.addAll(friends);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
lastConversationRecyclerView.setHasFixedSize(true);
lastConversationRecyclerView.setLayoutManager(layoutManager);
lastConversationAdapter = new FriendsAdapter(getActivity(), lastConversationList, lastConversationRecyclerView);
lastConversationRecyclerView.setAdapter(lastConversationAdapter);
}
private void setFriendsRecycler(RecyclerView friendsRecyclerView, List<Edge<Friends>> friends){
friendsList.addAll(friends);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
friendsRecyclerView.setHasFixedSize(true);
friendsRecyclerView.setLayoutManager(layoutManager);
friendsAdapter = new FriendsAdapter(getActivity(), friendsList, friendsRecyclerView);
friendsAdapter.setOnLoadMoreListener(friendsListener);
friendsRecyclerView.setAdapter(friendsAdapter);
}
I also try different combination with setNestedScrollingEnabled, but result was the same.
I have already found solution and what is wrongs with my code. It's work code, maybe someone have the same issue.
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/friendSwipeToRefresh">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/noFriendsTitle"
android:layout_marginTop="@dimen/marginTop"
android:layout_centerHorizontal="true"
android:visibility="gone"
android:text="@string/no_friends_title"/>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBarGetFriends"
android:layout_centerInParent="true"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainFriendsRelative"
android:paddingTop="@dimen/marginTopSmall"
android:paddingBottom="@dimen/marginTopSmall"
android:visibility="invisible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/paddingStart"
android:id="@+id/lastConversationTitle"
android:text="@string/friends_important_title"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lastChatFriendsRecyclerView"
android:layout_below="@+id/lastConversationTitle"
android:layout_marginTop="@dimen/marginTopSmall"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/paddingStart"
android:layout_below="@+id/lastChatFriendsRecyclerView"
android:layout_marginTop="@dimen/marginTopSmall"
android:id="@+id/allFriendsTitle"
android:text="@string/friends_all"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/friendsRecyclerView"
android:layout_marginTop="@dimen/marginTopSmall"
android:layout_below="@+id/allFriendsTitle" />
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
Fragment
private void setLastConversationFriendsRecycler(RecyclerView lastConversationRecyclerView, List<Edge<Friends>> friends){
lastConversationList.addAll(friends);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
lastConversationRecyclerView.setHasFixedSize(true);
lastConversationRecyclerView.setNestedScrollingEnabled(false);
lastConversationRecyclerView.setLayoutManager(layoutManager);
lastConversationAdapter = new FriendsAdapter(getActivity(), lastConversationList, lastConversationRecyclerView);
lastConversationRecyclerView.setAdapter(lastConversationAdapter);
}
private void setFriendsRecycler(RecyclerView friendsRecyclerView, List<Edge<Friends>> friends){
friendsList.addAll(friends);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
friendsRecyclerView.setHasFixedSize(true);
friendsRecyclerView.setNestedScrollingEnabled(false);
friendsRecyclerView.setLayoutManager(layoutManager);
friendsAdapter = new FriendsAdapter(getActivity(), friendsList, friendsRecyclerView);
friendsAdapter.setOnLoadMoreListener(friendsListener);
friendsRecyclerView.setAdapter(friendsAdapter);
}
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