The zoomed-out effect of the image is achieved using an open source project on GitHub, PhotoView: Https://github.com/chrisbanes/PhotoView
Here's a look at the test code:
Activity_main.xml:
1 <Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"2 Xmlns:tools= "Http://schemas.android.com/tools"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent" >5 6 <Android.support.v4.view.ViewPager7 Android:id= "@+id/viewpager"8 Android:layout_width= "Match_parent"9 Android:layout_height= "Match_parent" >Ten </Android.support.v4.view.ViewPager> One A </Relativelayout>
Mainactivity.java:
1 PackageCom.zzw.tetsphotoview;2 3 Importjava.util.ArrayList;4 Importjava.util.List;5 6 ImportUk.co.senab.photoview.PhotoViewAttacher;7 8 Importandroid.app.Activity;9 ImportAndroid.content.Context;Ten ImportAndroid.os.Bundle; One ImportAndroid.os.Handler; A ImportAndroid.os.Message; - ImportAndroid.support.v4.view.PagerAdapter; - ImportAndroid.support.v4.view.ViewPager; the ImportAndroid.view.View; - ImportAndroid.view.ViewGroup; - ImportAndroid.widget.ImageView; - + Public classMainactivityextendsActivity { - Viewpager Mviewpager; +List<imageview>imageviews; A at @Override - protected voidonCreate (Bundle savedinstancestate) { - Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); -Mviewpager =(Viewpager) Findviewbyid (R.id.viewpager); -Mviewpager.setadapter (NewImageadapter ( This)); in } - to classImageadapterextendsPageradapter { + context context; - int[] images; the * Public voidinit () { $Imageviews =NewArraylist<imageview>();Panax NotoginsengImages =New int[] {r.drawable.a, r.drawable.b, r.drawable.c, R.DRAWABLE.D}; - for(inti = 0; i < images.length; i++) { theImageView image =NewImageView (context); + Image.setimageresource (Images[i]); A the //The ability to zoom in and out of a picture + photoviewattacher mattacher=new photoviewattacher (image); - $ $ Imageviews.add (image); - - the } - //for (int i:images) {Wuyi //ImageView image = new ImageView (context); the //Image.setimageresource (i); - //Imageviews.add (image); Wu // } - } About $ PublicImageadapter (Context context) { - This. Context =context; - init (); - } A + @Override the Public voidDestroyitem (ViewGroup container,intposition, Object object) { - Container.removeview (imageviews.get (position)); $ } the the @Override the PublicView Instantiateitem (ViewGroup container,intposition) { the Container.addview (imageviews.get (position)); - in returnImageviews.get (position); the } the About @Override the Public intGetCount () { the returnimageviews.size (); the } + - @Override the Public BooleanIsviewfromobject (View arg0, Object arg1) {Bayi returnarg0 = =arg1; the } the - } - the}
Zoom in and out (use smooth display with Viewpager)--third party open source--photoview