I can use nested scroll view to have two recycler view but issue with that is recycler view is no more recycler view as it inflates all the view at once and if I add a on scroll listener to any recycler view then you will see all items are visible at once.
Is there any way where I can achieve scrollability of both recycler view at once.
Use Case:
I need to show scheduled events on top of history of events. I just want that both behaves as one big recycler view maintained individually. I don't mind showing all scheduled events before history of events.
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/pullToRefresh"
app:layout_constraintTop_toBottomOf="@+id/view_meetings_above_divider"
app:layout_constraintBottom_toTopOf="@+id/inviteContactImage"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="0dp">
<androidx.core.widget.NestedScrollView
android:id="@+id/nestedScrollView"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:paddingBottom="@dimen/dp_30"
>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:orientation="vertical"
android:id="@+id/upcomingScheduledEvent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<View
android:id="@+id/view_history_above_divider"
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#EEEEEE"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recentEvents"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
android:nestedScrollingEnabled="true"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />
<LinearLayout
android:id="@+id/noRecentEvents"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:layout_marginTop="@dimen/dp_10"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/px_32"
android:text="@string/find_your_colleagues_and_friends_to_chat"
android:textColor="@color/black"
android:textSize="@dimen/dp_14" />
<TextView
android:id="@+id/id_startSearch"
android:layout_width="125dp"
android:layout_height="36dp"
android:layout_marginTop="20dp"
android:background="@drawable/no_meeting_round_button_drawable"
android:gravity="center"
android:text="@string/chat_now"
android:textColor="@color/action_bar_color"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
I used a heterogeneous recycler view with three views. First is the scheduled events which are always on top, then the separator and then the recent event views. Read more about multiple views in a recycler view or heterogeneous recycler view.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.