Android中scrollTo和scrollBy的区别以及Scroller源码解析
展开全部
* 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(int x, int y) {//滑动到的目标坐标
if (mScrollX != x || mScrollY != y) {
int oldX = mScrollX;//已经滑动到的X
int oldY = mScrollY;//已经滑动到的Y
mScrollX = x;
mScrollY = y;
onScrollChanged(mScrollX, mScrollY, oldX, oldY);//调用说明状态改变
if (!awakenScrollBars()) {
invalidate();//通知视图进行重绘
}
* {@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(int x, int y) {//滑动到的目标坐标
if (mScrollX != x || mScrollY != y) {
int oldX = mScrollX;//已经滑动到的X
int oldY = mScrollY;//已经滑动到的Y
mScrollX = x;
mScrollY = y;
onScrollChanged(mScrollX, mScrollY, oldX, oldY);//调用说明状态改变
if (!awakenScrollBars()) {
invalidate();//通知视图进行重绘
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询