Android control for jelly sliding effect

preface

In wechat, the processing method is to let the user slide, but finally roll back to the original place. This effect is very vivid (after all, success still depends on details). So what are we going to do on Android. Now let's introduce jellyscrollview, a jelly sliding control with damping effect that I inherit from Scrollview.

Let's take a look at the renderings

(the virtual machine or real machine runs very smoothly. It may be a bit stuck when recording video into GIF.)

Implementation principle

In fact, you only need to rewrite the logic of its intercepting method. The intercepting method onintercepttouchevent of Scrollview generally returns false by default, indicating that the event is not intercepted. We just need to intercept and move the layout when the user slides the interface, and restore the layout when the user releases his hand. It's simple

Step 1: integrate Scrollview and rewrite several construction methods;

Step 2: rewrite the onfinishinflate method to obtain the first child view;

Step 3: process the above logic in the interception method;

Then use our jellyscrollview in the outermost layer of the layout

(I just wrote a part of the layout code for the convenience of display)

summary

Well, in this way, you can gracefully realize the effect of jelly control. The above is the whole content of this article. I hope the content of this article can be helpful to you. If you have any questions, you can leave a message.

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
分享
二维码
< <上一篇
下一篇>>