Method of realizing sliding distance listener in Scrollview in Android

preface

As we all know, Scrollview is a UI control we often use. Maybe you will find that when you want to monitor the sliding distance of Scrollview, there is no appropriate listener! Of course, there is @ h in API 23_ 404_ 7@setOnScrollchangelistener (view. Onscrollchangelister L) can be used, but it is not compatible with lower versions of the API. Then what shall I do? We have to rewrite Scrollview to monitor the sliding distance.

Don't say much, just go to the code:

The myscrollview rewritten above is in @ H_ 404_ 7@computeScroll () implement listening, because Scrollview is internally implemented through scroller, and @ h will be called when sliding_ 404_ 7@computeScroll () method, so as to achieve the effect of monitoring.

Of course, there is another way, that is, in @ H_ 404_ 7@onScrollChanged (Int l, int t, int oldl, int oldt) listen. The final effect is the same:

summary

The above is the whole content of this article. I hope it can be helpful to Android developers. 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
分享
二维码
< <上一篇
下一篇>>