RecyclerView SCROLL_STATE_IDLE is being called lat

2019-05-21 04:57发布

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.

The root view of the layout is CoordinatorLayout.

2条回答
啃猪蹄的小仙女
2楼-- · 2019-05-21 05:09

Invoke stopScroll() when your recyclerview has been reached to to bottom. I think Since it's support library version up, velocity is calulated and it makes delay a little.

查看更多
Root(大扎)
3楼-- · 2019-05-21 05:16

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();
    }
}

Update

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

查看更多
登录 后发表回答