view 基础与滑动

1. x = left + translationX


left 表示原始位置信息,在偏移过程中不变
translationX 表示偏移量
x 表示偏移后view 左上角的坐标


这三个参数都是相对于父容器的值


2. scrollTo  scrollBy 滑动的是view的内容


scrollTo(10, 10) 表示向左向上移动


getScrollX 表示view的内容相对于自身边框的偏移量


3. 通过动画平移


View动画 是影像平移
属性动画是真实平移


4. Scroller


startScroll(int startX, int startY, int dx, int dy, int duration)
startScroll指定参数,不执行实际滑动


实际滑动由重绘配合 computeScroll 方法实现

猜你喜欢

转载自blog.csdn.net/u013738122/article/details/80481744