scwang90 / SmartRefreshLayout

🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。
https://segmentfault.com/a/1190000010066071
Apache License 2.0
24.95k stars 4.95k forks source link

嵌套滚动不会自动加载 #1526

Open ozy1996 opened 1 year ago

ozy1996 commented 1 year ago

当布局CoordinatorLayout + AppBarLayout + recyclerview的时候,手指一直拖着到底部时不会触发滚动,需要手抬起来再次上拉才会触发加载。demo中的 嵌套滚动-整体滚动的页面也是这样

xuzhu19930323 commented 1 year ago

我的也是SmartRefreshLayout嵌套CoordinatorLayout,id为flContainer,动态Fragment替换生成列表,上拉加载功能失效,是滑动冲突了,有没有好的解决方案?

<com.scwang.smartrefresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/id_sm_refresh_layout" app:srlFooterTranslationViewId="@+id/flContainer" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/color_191D24"

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/transparent"
        app:elevation="0dp">

        <!-- 头部-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginHorizontal="@dimen/dp_10"
                android:layout_marginTop="@dimen/dp_10"
                android:background="@drawable/shape_r18_21262f"
                android:paddingHorizontal="@dimen/dp_15"
                android:paddingVertical="@dimen/dp_18">

                <TextView
                    android:id="@+id/tv_balance_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:drawablePadding="@dimen/dp_5"
                    android:fontFamily="@font/pingfang_medium"
                    android:paddingEnd="@dimen/dp_15"
                    android:text="@string/quotation_first_total"
                    android:textColor="@color/color_868D9A"
                    android:textSize="@dimen/sp_13"
                    app:drawableEndCompat="@drawable/ic_gray_eye_close" />

                <TextView
                    android:id="@+id/click_connect_wallet"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/tv_balance_title"
                    android:layout_marginTop="@dimen/dp_10"
                    android:drawablePadding="@dimen/dp_5"
                    android:fontFamily="@font/pingfang_medium"
                    android:gravity="center_vertical"
                    android:text="@string/click_connect_wallet"
                    android:textColor="@color/white"
                    android:textSize="@dimen/sp_16"
                    app:drawableEndCompat="@drawable/enter_right" />

                <TextView
                    android:id="@+id/tv_balance"
                    android:layout_width="wrap_content"
                    android:layout_height="@dimen/dp_24"
                    android:layout_below="@id/tv_balance_title"
                    android:layout_marginTop="@dimen/dp_10"
                    android:layout_marginEnd="@dimen/dp_6"
                    android:fontFamily="@font/roboto_medium"
                    android:gravity="center"
                    android:maxWidth="160dp"
                    android:maxLines="1"
                    android:text="0.00"
                    android:textColor="@color/white"
                    android:textSize="@dimen/sp_20"
                    android:visibility="gone"
                    app:textSizeDefault="@dimen/sp_20"
                    app:textSizeMin="@dimen/sp_16" />

                <TextView
                    android:id="@+id/first_unit"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignBaseline="@id/tv_balance"
                    android:layout_toEndOf="@id/tv_balance"
                    android:drawablePadding="@dimen/dp_5"
                    android:fontFamily="@font/roboto_regular"
                    android:gravity="center_vertical"
                    android:textColor="@color/white"
                    android:textSize="@dimen/sp_14"
                    android:visibility="gone"
                    app:drawableEndCompat="@drawable/icon_arrow_down"
                    tools:text="CNY" />

                <Button
                    android:id="@+id/first_recharge"
                    style="@style/app_submit_button_style"
                    android:layout_width="@dimen/dp_80"
                    android:layout_height="@dimen/dp_34"
                    android:layout_alignBaseline="@id/tv_balance"
                    android:layout_alignParentEnd="true"
                    android:layout_marginEnd="0dp"
                    android:layout_marginTop="0dp"
                    android:layout_marginBottom="0dp"
                    android:background="@drawable/binance_shape_r5_f5d558"
                    android:fontFamily="@font/pingfang_medium"
                    android:textStyle="bold"
                    android:text="@string/ASSET_RECHARGE"
                    android:textSize="@dimen/sp_14"
                    android:visibility="gone" />
            </RelativeLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginVertical="@dimen/dp_18"
                android:orientation="horizontal"
                android:weightSum="5">

                <TextView
                    android:id="@+id/home_rank"
                    style="@style/quotation_first_page_grid_style"
                    android:text="@string/quotation_first_page_rank"
                    app:drawableTopCompat="@drawable/home_rank" />

                <TextView
                    android:id="@+id/home_strategy_trade"
                    style="@style/quotation_first_page_grid_style"
                    android:text="@string/quotation_first_page_strategy"
                    app:drawableTopCompat="@drawable/home_strategy_trade" />

                <TextView
                    android:id="@+id/home_contract_trade"
                    style="@style/quotation_first_page_grid_style"
                    android:text="@string/quotation_first_page_future"
                    app:drawableTopCompat="@drawable/home_contract_trade" />

                <TextView
                    android:id="@+id/home_help_center"
                    style="@style/quotation_first_page_grid_style"
                    android:text="@string/quotation_first_help_center"
                    app:drawableTopCompat="@drawable/home_help_center" />

                <TextView
                    android:id="@+id/home_trade_cal"
                    style="@style/quotation_first_page_grid_style"
                    android:text="@string/quotation_first_transaction"
                    app:drawableTopCompat="@drawable/home_trade_cal" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/recharge_door"
                android:layout_width="match_parent"
                android:layout_height="@dimen/dp_45"
                android:layout_marginHorizontal="@dimen/dp_10"
                android:layout_marginBottom="@dimen/dp_15"
                android:paddingHorizontal="@dimen/dp_15"
                android:background="@drawable/quotation_first_action_u_shape"
                android:gravity="center_vertical"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="@dimen/dp_48"
                    android:layout_height="@dimen/dp_34"
                    android:src="@drawable/first_u_action_icon"/>

                <TextView
                    android:id="@+id/recharge_door_hint"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="wrap_content"
                    android:fontFamily="@font/roboto_medium"
                    android:textSize="@dimen/sp_12"
                    app:textSizeDefault="@dimen/sp_12"
                    app:textSizeMin="@dimen/sp_10"
                    android:textColor="@color/white"
                    android:layout_marginStart="@dimen/dp_8"
                    android:text="@string/action_u_first_page_usdt_hint"/>

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="@dimen/sp_12"
                    android:textColor="@color/color_F5D558"
                    android:fontFamily="@font/pingfang_bold"
                    android:layout_marginStart="@dimen/dp_8"
                    android:text="@string/first_action_u_confirm"/>

                <ImageView
                    android:layout_width="@dimen/dp_12"
                    android:layout_height="@dimen/dp_12"
                    android:layout_marginStart="@dimen/dp_3"
                    android:src="@drawable/quotation_firstpage_arrow"/>
            </LinearLayout>
        </LinearLayout>
    </com.google.android.material.appbar.AppBarLayout>

    <LinearLayout
        android:id="@+id/ll_scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        app:leftTopRadius="@dimen/dp_18"
        app:rightTopRadius="@dimen/dp_18">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/tabRv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/color_21262F"
            android:overScrollMode="never"
            android:paddingHorizontal="@dimen/dp_5"
            android:paddingTop="@dimen/dp_14"
            android:scrollbars="none" />

        <FrameLayout
            android:id="@+id/flContainer"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="@color/color_21262F" />

    </LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

</com.scwang.smartrefresh.layout.SmartRefreshLayout>

ozy1996 commented 1 year ago

我的也是SmartRefreshLayout嵌套CoordinatorLayout,id为flContainer,动态Fragment替换生成列表,上拉加载功能失效,是滑动冲突了,有没有好的解决方案?

```

我改用adapter的上拉加载了

xuzhu19930323 commented 1 year ago

这种方案可以的,希望作者能够修复掉这个bug比较好点

Louis0704 commented 1 year ago

我开始和你们问题一样,后来找人帮我看了下对比作者的源代码,发现是因为没加footer。。。smartRefreshLayout.setRefreshFooter(new ClassicsFooter(this))之后就好了。。