smoothScrollToPositionFromTop和smoothScrollToPosition的区别

首先,学一个英语短语:
such that 使得满足…的条件
两者的API文档分别如下:

AbsListView.smoothScrollToPositionFromTop:
Smoothly scroll to the specified adapter position.The view will scroll such that the indicated position is displayed offset pixels below the top edge of the view.
流畅地滚动到指定位置。这个listview将滚动,直到指定position位置的view显示在离顶端offset个像素的位置。
	
ListView.smoothScrollToPosition
Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed.
流畅地滚动到指定位置。这个listview将滚动,直到指定position位置的view显示出来。

smoothScrollToPosition:只是滑到指定位置的view在屏幕上显示出来,只要显示出来,就不再滑动,不管显示在屏幕最上方还是最下方。有时候会失效,就是因为已经指定位置的view已经显示在屏幕上了,如果想显示在指定的位置,需要使用smoothScrollToPositionFromTop,使指定位置的view显示在离父布局顶端N个像素的位置。或者指定smoothScrollToPosition,参数列表中的position一个偏移量,使未显示的view显示出来,将需要摆放位置的view向特定方向挤压过去,以达到指定view的位置的目的。

view:The view whose scroll state is being reported
firstVisibleItem:the index of the first visible cell (ignore if visibleItemCount == 0)
visibleItemCount:the number of visible cells
totalItemCount:the number of items in the list adaptor

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值