Question

Im trying to implement inertial scrolling 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);
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top