0
我有兩個Recyclerview
裏面NestedScrollView
。第二個Recyclerview
也有SwipeRefreshLayout
。我嘗試爲兩個回收站設置一個滾動條,但我的解決方案沒有工作。兩個回收卷軸分開,我沒有解決方案,請幫助我。提前致謝。我的代碼滾動兩個recyclerView作爲一個
<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>
我的片段代碼
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);
}
我也嘗試不同的組合setNestedScrollingEnabled
,但結果是一樣的。
你的意思是你已經設置setNestedScrollingEnabled(假)爲您的RecyclerViews的? –
是的,當我爲這兩個回收站設置false時,滾動是禁用的,我無法滾動任何東西 –
您還在尋找答案嗎? –