recycleView scrollToPosition 现象
来源:互联网 发布:淘宝客服务费结算方式 编辑:程序博客网 时间:2024/06/05 13:25
如果position对应的view已经显示出来了,那么是不会有滑动现象的
原因?
LinearLayoutManager类中的onLayouthildren方法,约483行
updateAnchorInfoForLayout(recycler, state, mAnchorInfo);
if (updateAnchorFromPendingData(state, anchorInfo)) { if (DEBUG) { Log.d(TAG, "updated anchor info from pending information"); } return; }
mReverseLayout
Defines if layout should be calculated from end to start.
就是说反过来的布局,默认是false的
// item is not visible.
if (mPendingScrollPositionOffset == INVALID_OFFSET) {
if (getChildCount() > 0) {
// get position of any child, does not matter
int pos = getPosition(getChildAt(0));
anchorInfo.mLayoutFromEnd = mPendingScrollPosition < pos
== mShouldReverseLayout;
}
就是说,如果第一个visible的position 是6,而我要移动到的是第10个,
如果不是反过来布局的,那么就从end开始
so, 调用带有offset的方法,但是参数传0,就可以了
补充:2017-1-4
如果activity是RelativeLayout,recyclerVuiew会两次调用child.Layout,并且当最后一页的时候,例如显示了3的一半,4,5,(6未显示完全),scrollToPositionWithOffset这个时候如果要滚动到3,理想中的位置是3在最顶部,然而,如果recycler below 一个view A,那么,3不会滚动到顶部,而是,距离顶部有一个viewA的距离,也就是说距离屏幕顶部有2个viewA的距离,解决办法 把activity由RelativeLayout改为LinearLayout
- recycleView scrollToPosition 现象
- ScrollView嵌套recycleView出现的卡顿现象
- RecyclerView scrollToPosition 无效的问题
- recycleView
- RecycleView
- RecycleView
- RecycleView
- RecycleView
- RecycleView
- RecycleView
- recycleview
- RecycleView
- RecycleView
- RecycleView
- RecycleView
- RecycleView
- recycleview
- RecycleView及RecycleView Adapter
- 使用ASP.Net WebAPI构建REST服务(一)——简单的示例
- Linux 挂载硬盘
- git .ssh 公钥
- 寻找和为Sum的多个数-1
- Java之简单输入输出数据
- recycleView scrollToPosition 现象
- 多进程编程之进程间通信-管道和消息队列
- 【Bash百宝箱】shell内建命令之read、readarray、mapfile
- Spring MVC
- HUD 1004
- 一句话总结我的校招
- JQuery中的事件和动画
- 2-2.HDFS的shell操作(Hadoop系列day02)
- 【翻译】ASP.NET Web API入门