想要在嵌套滚动视图中使用回收器视图
我正在使用带有多个视图的回收视图,其中循环器工作正常,但是当我将回收器视图放在嵌套的滚动视图中时,嵌套视图的滚动是滞后的,或者您可以在新项目时说延迟几秒钟。加入回收器视图 为了清楚起见,我已经将回收器视图嵌套滚动设置 而且我正在使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其添加到您的回收范围
Add this to your RecyclerView