簡體   English   中英

滾動視圖中的兩個回收器視圖

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM