[英]Two recycler view inside a scroll view
我可以使用嵌套滚动视图来拥有两个回收器视图,但问题是回收器视图不再是回收器视图,因为它一次膨胀所有视图,如果我将滚动监听器添加到任何回收器视图,那么你会看到所有项目都是一下子可见。
有什么方法可以同时实现两个回收器视图的可滚动性。
用例:
我需要在事件历史记录之上显示预定事件。 我只是希望两者都表现为一个单独维护的大型回收器视图。 我不介意在事件历史之前显示所有预定的事件。
<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>
我使用了具有三个视图的异构回收器视图。 首先是始终位于顶部的预定事件,然后是分隔符,然后是最近的事件视图。 阅读更多关于回收者视图或异构回收者视图中的多个视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.