技术坑
Android下RecyclerView使用瀑布流布局滚动之后如何保持item相对位置不变
mtsym 发表于2019-06-17 浏览6027 评论0
RecyclerView采用StaggeredGridLayoutManager布局之后, 如果在滚动之后要保持item焦点位置相对不变, 只需要简单的代码处理就行了, 在滚动前记忆span位置, 滚动后通过遍历可视区域item, 定位相应span位置的view, 然后请求焦点, 大致如下
// 成员变量
int mSpanPosition = -1;
// 滚动之前记忆item相对位置
View focusChild = getFocusedChild();
<!--autointro-->