Detailed explanation of Android imitation headlines and wechat big picture preview view

Big picture preview @ h_ 419_ 5@

In my current project, there is also the function of large picture preview, but its implementation is too heavy. It is implemented with an activity, and there will be a Caton feeling in the process of picture display. The overall feeling is very bad. It happens that the project is also in the process of reconstruction, so I decided to write this function as a formed control@ H_ 419_ 5@

Don't say much. Let's see the effect in the figure above first@ H_ 419_ 5@

@H_ 419_ 5@ @H_ 419_ 5@

Overall realization idea @ h_ 419_ 5@

The control adopts the way of custom view and forms a control with large picture preview through the combination of some basic controls. Upper code @ h_ 419_ 5@

Usage @ h_ 419_ 5@

(1) Reference the view @ h in the layout file_ 419_ 5@

(2) Specific usage @ h_ 419_ 5@

It's over here. It's that simple@ H_ 419_ 5@

Concrete implementation @ h_ 419_ 5@

(1) Start with the showphotogallery (index, ImageView) @ H_ 419_ 5@

ImageView: that is, click the picture you want to display @ H_ 419_ 5@

(2) Process the data passed into galleryview @ h_ 419_ 5@

Through the ImageView passed in, obtain the clicked view parameter, assemble it into a parameter model, and then process the data@ H_ 419_ 5@

(3) Implementation mechanism of galleryview @ h_ 419_ 5@

The main implementation idea of the view is: the outermost layer is a relativelayout, and there is an ImageView and viewpager filled with parent layout inside. ImageView is used to animate and zoom the picture, and viewpager is used to display the last picture. In fact, the most important part of the view is the animation displayed by clicking ImageView to the last viewpager. The next step is to explain this place. First, take a look at the parameter model of the clicked ImageView. GalleryPhotoParameterModel@H_ 419_ 5@

3.1 picture enlargement operation @ h_ 419_ 5@

3.2 image reduction operation @ h_ 419_ 5@

3.3 calculate the zoom ratio of the picture @ h_ 419_ 5@

3.4 perform zoom of animation @ h_ 419_ 5@

The main implementation of changing the view is as above. When zooming the picture, the following conditions should be considered: short edge adaptation, the width and height of the original size of the picture, the width to height ratio of the ImageView displaying the picture, and the screen size in horizontal and vertical screens. Thank you very much for your help and boxing! Buddy. If you have more ideas@ H_ 419_ 5@

Please move to my GitHub galleryview address @ h_ 419_ 5@

Summary @ h_ 419_ 5@

The above is the whole content of this article. I hope the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips@ H_ 419_ 5@

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