想要在嵌套滚动视图中使用回收器视图

发布于 2025-02-13 11:14:42 字数 1890 浏览 1 评论 0原文

我正在使用带有多个视图的回收视图,其中循环器工作正常,但是当我将回收器视图放在嵌套的滚动视图中时,嵌套视图的滚动是滞后的,或者您可以在新项目时说延迟几秒钟。加入回收器视图 为了清楚起见,我已经将回收器视图嵌套滚动设置 而且我正在使用NestedScrollview,因为当用户进入回收器视图和加载更多项目时,我想显示进度栏,我也尝试将块后代添加到XML文件,但不起作用 我的XML代码:

<androidx.core.widget.NestedScrollView 
  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/home_fragement"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    


    android:overScrollMode="never"




    tools:context=".Content_Maint_Fragment.HomeFragment"

   >

<LinearLayout
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:focusableInTouchMode="true"
    android:focusable="true"
    android:descendantFocusability="blocksDescendants"
    android:layout_height="match_parent">


                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/home_recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"

                    android:overScrollMode="never"

                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                </androidx.recyclerview.widget.RecyclerView>

        <ProgressBar
            android:id="@+id/progressBar2"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"

            android:layout_height="wrap_content" />

</LinearLayout>
</androidx.core.widget.NestedScrollView>

I am using a recycler view with multiple views nested in it recycler work fine and it also scroll smoothly but when I put recycler view inside the nested scroll view the scroll of nested view is lag or you can say delay for few second when the new item is add in recycler view
.For clarity I already set the recycler view nested scroll to false
and I am using NestedScrollView because I want to show progress bar when user come to end of recycler view and load more item and I also try to add block descendant to xml file but not work
my xml code:

<androidx.core.widget.NestedScrollView 
  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/home_fragement"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    


    android:overScrollMode="never"




    tools:context=".Content_Maint_Fragment.HomeFragment"

   >

<LinearLayout
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:focusableInTouchMode="true"
    android:focusable="true"
    android:descendantFocusability="blocksDescendants"
    android:layout_height="match_parent">


                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/home_recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"

                    android:overScrollMode="never"

                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                </androidx.recyclerview.widget.RecyclerView>

        <ProgressBar
            android:id="@+id/progressBar2"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"

            android:layout_height="wrap_content" />

</LinearLayout>
</androidx.core.widget.NestedScrollView>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩人痒 2025-02-20 11:14:42
android:nestedScrollingEnabled="false"

将其添加到您的回收范围

android:nestedScrollingEnabled="false"

Add this to your RecyclerView

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文