RecyclerView 提供相當多種控制Scroll的方法
1.scrollBy(int x, int y)
2.scrollTo(int x, int y)
3.scrollToPosition(int position)
4.smoothScrollBy(int dx, int dy)
5.smoothScrollBy(int dx, int dy, Interpolator interpolator)
6.smoothScrollToPosition(int position)
其中ScrollToPosition與smoothScrollToPosition,
都只能讓指定的Position顯示在畫面上而具體位置在哪則無法控制。


若使用LinearLayoutManager的
scrollToPositionWithOffset(int position, int offset)
這個方法則解決了上面的問題其中若將offset設定為0則此position將置頂,
若為100則positionru將會停在距離上方100Pixel的位置。

文章標籤
全站熱搜
創作者介紹
創作者 你是誰 的頭像
你是誰

你是誰的部落格

你是誰 發表在 痞客邦 留言(0) 人氣(1)