Android realizes the synchronous scrolling effect code of mutual linkage between two scrollviews
This example describes the code of synchronous scrolling effect that Android realizes the interaction of two scrollviews. Share with you for your reference, as follows:
Recently, I was working on a project that used the effect of mutual linkage between two scrollviews. In short, the linkage effect means sliding one Scrollview and the other Scrollview together. It is necessary to slide together synchronously. I feel that you may also use it in future project development. Absolutely make a demo and share it for everyone to learn together, so that you can use it easily in the future. You feel good. You can collect what is useful first!
In fact, for Scrollview, the Android official does not provide relevant methods to obtain or set the sliding distance, nor does it provide corresponding monitoring methods. But how do you do that? Don't worry, you can do it. Since no monitoring method is provided, it can be seen from the Android source code that a method for X and Y distance is provided, as follows:
design sketch:
The specific implementation method is as follows:
1. Rewrite Scrollview
Through the above code, we can see that we have written a method to set listening, as follows:
Let's look at step 2. Define a listening interface.
2. Define listening interface
3. The layout file references the overridden observablescrollview
Don't write the specific content. Just cite an example, as follows:
4. call in Activity
That's it. What should be said is more clear.
I hope this article will help you in Android programming.