【问题标题】:RecyclerView setSelected and scrolling?RecyclerView setSelected 和滚动?
【发布时间】:2015-10-10 07:49:59
【问题描述】:

ListView 中,getListView().setSelection(n); 用于直接滚动,getListView().smoothScrollToPosition(n); 用于平滑滚动。

这在RecyclerView 中是否可行?

【问题讨论】:

标签: android android-recyclerview


【解决方案1】:

您必须使用scrollToPositionWithOffset

//Scroll item 2 to 20 pixels from the top
linearLayoutManager.scrollToPositionWithOffset(2, 20);

这个问题是answered before

【讨论】:

  • 抱歉这个不好的问题,但谢谢,答案对我来说是完美的:)
  • 我在寻找 ListView 的 setSelectionFromTop 的等效项时找到了这个答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-06-29
  • 1970-01-01
  • 1970-01-01
  • 2023-03-03
  • 2018-05-12
  • 1970-01-01
  • 2020-07-09
相关资源
最近更新 更多