Android realizes the sliding effect of exploring pictures

Some time ago, I played this software with the recommendation of my friends. When I first played it, I found that this software is very different from general social software such as Momo, which makes me refreshing. In particular, the image sliding operation in the exploration makes people feel very fresh. Therefore, I will wade through the experience of my predecessors before online and my own understanding. The following is the original interface of online search

At that time, I really wanted to achieve this kind of imitation and exploration effect by myself, but there was no idea. However, there is no doubt that the principle of this effect is certainly similar to that of listview / recyclerview, involving the recycling and reuse of item views. Otherwise, it would have been oom due to a large number of item views. Starting with view, recyclerview has its own item view recycling and reuse function. Moreover, the layout of recyclerview is realized by setting layoutmanager, which fully completes the layout and recyclerview.

Inherit recyclerview.layoutmanager and display the layout managed by yourself. For example, up to 4 views are displayed and all are displayed in the center. The view at the bottom also needs to be zoomed and panned

Google officially provides an itemtouch helper tool class, which encapsulates the sliding

Usage: new itemtouchhelper (callback). Attachtorecyclerview (recyclerview); It's that simple. The next operations are carried out in the callback

Layout files: card contents

Layout file: click the button

Listening function:

To sum up, we mainly used the custom layoutmanager and itemtouchhelper.callback in the whole code process. Next, let's see the effect:

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