Reprint Please specify source: http://blog.csdn.net/zhaokaiqiang1992
The open source project that we are going to introduce to you today is the Photoview project from GitHub, the main function of this project is to achieve the reduction of the image of the normal ImageView control, which includes single touch and multi touch.
PhotoView's GitHub project address: Https://github.com/chrisbanes/PhotoView
The folder structure of the test project
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvemhhb2thaxfpyw5nmtk5mg==/font/5a6l5l2t/fontsize/400/fill/ I0jbqkfcma==/dissolve/70/gravity/southeast ">
We can copy the Photoview resource files directly to the project.
Here are the key codes
Package Com.example.photoview;import Uk.co.senab.photoview.photoviewattacher;import Android.app.activity;import Android.graphics.drawable.drawable;import Android.os.bundle;import Android.widget.imageview;public Class Mainactivity extends Activity {private ImageView img;private photoviewattacher attacher; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); img = (ImageView) Findviewbyid (r.id.img);D rawable drawable = Getresources (). getdrawable (R.drawable.ico); Img.setimagedrawable (drawable); attacher = new Photoviewattacher (IMG); attacher.update ();}}
Let's say we're in the code behind. Used amimageview.setimagedrawable/setimagebitmap/setimageresource/and so on, we just need to call Attacher.update ().
Demo: Https://github.com/ZhaoKaiQiang/PhotoViewDemo
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
"Android Interface Implementation" photoview--single-point support/multi-image scaling for touch