Top pull-down and bottom pull-up springback effects of Android Scrollview

To achieve the rebound effect of Scrollview, you need to handle the touch event. Let's take a look at the simple effects:

According to the view event distribution and processing mechanism of Android, the dispatchtouchevent is analyzed in detail below:

After loading the layout, get the first child element of the Scrollview, save its parameters, the left top right bottom parameter, and carry out the layout parameters of the child view according to the top pull-down operation and the bottom pull-up operation. The layout parameters of the child view change according to the sliding distance, action_ When up, judge whether there is rebound. If necessary, animate the rebound to the original position. You can add a rebound end monitoring, such as monitoring the rebound processing and jumping to other pages.

The specific implementation is as follows, adding the parameter setting of whether to disable the top and bottom springback, and the end monitoring of the springback effect.

use:

Just replace the Scrollview with reboundscrollview in the XML layout file. You can also add other animation effects to the top and bottom of the rebound (try again later).

If you need to disable springback, you can directly set the enabletoprebound and enablebottombound parameters, and also set the springback end (or start) listening.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>