The elastic slide of the view
Realize the idea of elastic sliding: A large slide is divided into several small sliding and completed in a time period, the specific implementation of a number of ways, such as through Scroller, handler#postdelayed and Thread#sleep and so on.
First, the use of scroller
A typical use method
The implementation of the elastic slide: When the view is redrawn, the computescroll is called in the Draw method, and Computescroll goes to Scroller to get the current scrollx and scrolly, and then the Scrollto method for sliding And then calls the Postinvalidate method for a second redraw, which, like the first redraw, causes the Computescroll method to be called, and then continues to get the current scrollx and scrolly to Scroller. and slide to the new position through the Scrollto method, so repeat until the entire sliding process is over.
Second, through the animation
Third, the use of delay policy
1. Using handler
The Postdelayed method of 2.View
3. Using the thread's Sleep method
The elastic slide of the view