簡體   English   中英

Android SwipeToRefresh-向下滑動時與RecyclerView沖突

[英]Android SwipeToRefresh - Confilct with RecyclerView when swiping down

因此,我有一個包含2個RecyclerView列表的片段。 我想滑動片段以刷新那些列表,但是當我滾動那些列表之一以查看隱藏的元素時,SwipeToRefresh刷新了這些列表。 如何防止這種情況發生?

這是我的XML布局:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/main_fragment">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/main_fragment_swipe_to_refresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.CoordinatorLayout
            android:id="@+id/main_fragment_coordinator_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:weightSum="2">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:layout_weight="1">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="4dp"
                        android:textSize="18sp"
                        android:textColor="@color/primary_dark"
                        android:text="Najpopularniejsze przepisy" />

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/top_recipes_recycler_view"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:scrollbars="vertical" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    android:layout_weight="1">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="4dp"
                        android:textSize="18sp"
                        android:textColor="@color/primary_dark"
                        android:text="Najnowsze przepisy" />

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/latest_recipes_recycler_view"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:scrollbars="vertical" />

                </LinearLayout>

            </LinearLayout>

        </android.support.design.widget.CoordinatorLayout>

    </android.support.v4.widget.SwipeRefreshLayout>

</FrameLayout>

有任何想法嗎?

您可以在RecycleView向上滾動時使用其向下滑動事件。

只需自定義RecycleView並在需要時截取該事件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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