Android------Achieve a picture double click to zoom in, zoom out, swipe left and right in various ways

Source: Internet
Author: User

There are often picture-browsing features in the project. Like a friend circle picture browsing, QQ space photo browsing features.

Realize the picture double-click Enlarge, shrink, left and right slide effect.

Come and see me, I hope I can meet your demands.

The top three button buttons are various implementations of the reference network, three custom picture controls,

The 4th one is Viewpager realize the picture left and right slide

 Public classViewpagerimageviewzquiextendsappcompatactivity {Viewpager viewpager; Private int[] Mimgs =New int[] {r.mipmap.img1, r.mipmap.img2, r.mipmap.tour};    Imageview[] Mimageviews; @Overrideprotected voidonCreate (@Nullable Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (r.layout.viewpager_layout);    Initview (); }    Private voidInitview () {mimageviews=NewImageview[mimgs.length]; Viewpager=(Viewpager) Findviewbyid (R.id.img_viewpager); Viewpager.setadapter (NewPageradapter () {@Override PublicObject Instantiateitem (ViewGroup container,intposition) {                //You can use other ImageView controls, other custom controls, you can also use your own OhTounchimageview tounchimageview=NewTounchimageview (Viewpagerimageviewzqui. This); Try{picasso.with (viewpagerimageviewzqui). This). Load (Mimgs[position]). Placeholder (R.MIPMAP.IMG1)//the picture that is displayed by default//. Resize (500,300)//control the height of the picture, not add it adaptive. Error (R.mipmap.ic_launcher)//a picture appears incorrectly when loading. into (Tounchimageview); } Catch(Exception e) {}//Click BackTounchimageview.setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (View v) {finish ();                }                }); Container.addview (Tounchimageview, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_                CONTENT); Mimageviews[position]=Tounchimageview; returnTounchimageview; } @Override Public intGetCount () {returnmimgs.length; } @Override Public voidDestroyitem (ViewGroup container,intposition, Object object)            {Container.removeview (mimageviews[position]); } @Override Public BooleanIsviewfromobject (View arg0, Object arg1) {returnarg0 = =arg1;    }        }); }}

The 5th button mainly refers to the PhotoView of the use of a variety of ways, leaflets, rotation, viewpager,gridview, etc.

Because the interface is too many, not upload too many pictures, download run See effect can.

Code Portal

Android------Achieve a picture double click to zoom in, zoom out, swipe left and right in various ways

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.