Solution 1 :
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.
Problem :
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>
Comments
Comment posted by ZBorkala
Can you show your code, please? So that, we can help you somehow.
Comment posted by Tarun Chawla
Will share in a min.
Comment posted by Tarun Chawla
@ZBorkala please check.
Comment posted by ZBorkala
If you also provide a screenshot of the current result, that would be better.
Comment posted by Tarun Chawla
Upcoming schedule event recylcer and recent view recycler are scrolling at once.