【问题标题】:Recyclerview smooth scrolling errorRecyclerview平滑滚动报错
【发布时间】:2017-03-09 06:09:51
【问题描述】:

我正在尝试使用线性布局管理器平滑滚动到 recyclerview 中的某个位置。

void smoothScrollToPosition(int position)

但是,它并不总是能正常工作。有时,它会将我带到列表的底部,并且在日志中,我收到以下错误消息

Passed over target position while smooth scrolling

我在 SO 中找到了 this thread。但是,答案并没有解释为什么会出现错误,它有解决问题的方法。很长一段时间以来,我一直试图弄清楚这一点。有人能解释一下什么时候会抛出这个错误吗?

【问题讨论】:

    标签: android scroll android-recyclerview linearlayoutmanager


    【解决方案1】:

    尝试在后台线程中调用smoothScrollToPosition。使用recyclerView.post()。我猜适配器在忙时可能会在生成项目视图时丢失数据。

    【讨论】:

      猜你喜欢
      • 2017-01-16
      • 1970-01-01
      • 1970-01-01
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多