Im trying to implement inertial scroll开发者_JS百科ing in my GLSurfaceView and to do that i need to figure out how to calculate velocity, but im not sure how to do so. the translation is stored in a matrix, and it is calculated by the line of code below.
matrix.postTranslate(event.getX() - start.x,event.getY() - start.y);
Take a look at the Scroller
and VelocityTracker
classes. Together they are used to implement fling behavior in the standard framework widgets. Use these and your app will always match the native feel of the device.
精彩评论