SmartRefreshLayout 嵌套滚动不会自动加载

e3bfsja2  于 4个月前  发布在  其他
关注(0)|答案(4)|浏览(47)

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

q1qsirdb

q1qsirdb1#

我的也是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>

uqjltbpv

uqjltbpv2#

我的也是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>

我改用adapter的上拉加载了

rjzwgtxy

rjzwgtxy3#

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

jutyujz0

jutyujz04#

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

相关问题