垂直RecyclerView内的水平RecyclerViews滚动抖动 [英] Horizontal RecyclerViews inside vertical RecyclerView scrolling jerks

查看:695
本文介绍了垂直RecyclerView内的水平RecyclerViews滚动抖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的布局中,我使用了多个RecyclerViews(水平)作为RecyclerView的项目视图.问题是垂直滚动不像我期望的那样平滑.垂直滚动(Parent RecyclerView)时会出现一些抖动.

I am using a layout in which I used multiple RecyclerViews (Horizontal) as a item view of RecyclerView. The problem is that the vertical scrolling is not as smooth as I am expecting.There are some jerks in while scrolling vertically(Parent RecyclerView).

如何去除这些垂直滚动抖动?我曾经在Parent RecyclerView的OnBindViewHolder()方法中将适配器设置为水平RecyclerView.

How to remove these vertical scrolling jerks ? I used to set adapters to horizontal RecyclerViews in OnBindViewHolder() method of Parent RecyclerView.

推荐答案

我已经解决了问题.

在这种情况下,滚动性能要好得多.

Scrolling performance is much better in this case.

不要在父级RecyclerViewOnBindViewHolder()方法中将适配器设置为水平RecyclerViews.

Do not set adapters to horizontal RecyclerViews in OnBindViewHolder() method of Parent RecyclerView.

它不是通过RecyclerView的onCreateViewHolder()创建的具有空或空dataList的视图时第一次设置的.

Instead of it set it at very first time when the view is created via onCreateViewHolder() of RecyclerView with empty or null dataList.

只需用onBindViewHolder()上的空列表替换新的辅助数据列表,然后将notifydataSetChanged()调用到HorizontalAdapetr.

Just replace the new secondary data list with previous null list at onBindViewHolder() and call notifydataSetChanged() to HorizontalAdapetr.

这比onBindViewHolder()中的setAdapter()好得多.

这篇关于垂直RecyclerView内的水平RecyclerViews滚动抖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆