I've seen it before xiaanming The side slip is written to return, so it follows his Demo and writes the slide from top to bottom or the slide from bottom to top to end the Activity
Let's take a picture first. Because of the problem of the resolution of this computer and the reason of the simulator, let's have a look
Post code first:
Slide up and down:
To realize this, it is very simple. In onTouchEvent, judge the distance of finger movement. If it is greater than the threshold value set by yourself, scroll to the top or the bottom, otherwise return to the initial position. So here we use the Scroller, scroller.startScroll After that, postInvalidate refreshes the interface.
Finally, rewrite computeScroll to determine whether the Scroller has finish ed and whether the distance of finger movement is greater than the threshold value set by itself.
Finally, remember that AndroidManifest.xml Set the theme of Activity to Theme.Translucent Otherwise, no effect will be seen
Reproduced from: http://blog.csdn.net/qq_18612815/article/details/52353078