RecyclerView SCROLL_STATE_IDLE被延迟调用 [英] RecyclerView SCROLL_STATE_IDLE is being called late

本文介绍了RecyclerView SCROLL_STATE_IDLE被延迟调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在RecyclerView addOnScrollListener上,属性SCROLL_STATE_IDLE需要花费时间才能在项目大小的末尾以及向上滚动到RecyclerView的顶部时被调用.但是在滚动过程中效果很好.

On RecyclerView addOnScrollListener the property SCROLL_STATE_IDLE takes time to get called at end of the item size and when scrolled up to the top of the RecyclerView. But it works fine in middle of the scrolling.

布局的根视图是CoordinatorLayout.

The root view of the layout is CoordinatorLayout.

推荐答案

遇到相同的问题,我发现的唯一解决方法是,每当RecyclerView收到时,发送 stopScroll() > SCROLL_STATE_SETTLING ,尽管不是理想的解决方案.考虑到滚动方向,最好检测它是否到达顶部或底部边缘,然后调用stopScroll():

Having the same issue, the only workaround I've found is to send a stopScroll() whenever the RecyclerView gets a SCROLL_STATE_SETTLING, though not the ideal solution. Probably would be better to detect if it has reached the top or bottom edge, taking into account the scrolling direction, and then call stopScroll():

@Override
public void onScrollStateChanged(final int state)
{
    super.onScrollStateChanged(state);

    if (state == RecyclerView.SCROLL_STATE_SETTLING)
    {
        this.stopScroll();
    }
}

更新

此问题似乎是支持库中的错误,尽管据报告已修复,很明显该问题仍然存在,所以希望我们将来能找到适当的解决方案:

This issue seems to be a bug in the support library, though it was reported as fixed its clear that the problem still exists, so hopefully we should see an adequate solution in the future:

https://issuetracker.google.com/issues/66996774

这篇关于RecyclerView SCROLL_STATE_IDLE被延迟调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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