本系列文章部分摘自《Android开发艺术探索》,目的是提取精干知识点加上自己部分理解作为备忘笔记,如有侵权请及时联系我,再次感谢作者,如喜欢请支持购买作者正版书籍
目录
View的滑动方式
View 的滑动主要通过三种方式实现:
- 通过View本身提供的scrollTo/scrollBy
- 通过动画实现View的滑动
- 通过改变View的LayoutParams使View重新布局实现滑动
scrollTo/scrollBy实现的滑动
本篇文章主要记录scrollTo/scrollBy实现的滑动
首先来看一段源码
/**
* Set the scrolled position of your view. This will cause a call to
* {@link #onScrollChanged(int, int, int, int)} and the view will be
* invalidated.
* @param x the x position to scroll to
* @param y the y position to scroll to
*/
public void scrollTo