- PhotoView能够放大缩小图片,可以使用双击或者双指缩放ImageView,非常方便好用
- 首先去github下载:http://github.com/chrisbanes/PhotoView
- 配置:
- 这个是在你的project的build.gradle里面配置的
<span style="font-family:SimSun;font-size:14px;">allprojects { repositories { jcenter() maven { url "https://jitpack.io"} }</span>
- 这个是在你的module的build.gradle里面配置的
<span style="font-family:SimSun;font-size:14px;">compile 'com.github.chrisbanes:PhotoView:1.3.0'</span>
- 具体如下:
-
然后在MainActivity的onCreate方法中给ImageView设置PhotoViewAttacher即可。如下:
<span style="font-family:SimSun;font-size:14px;">// 创建一个photoview的attacher PhotoViewAttacher photoViewAttacher = new PhotoViewAttacher(iv);</span>
-
这样,图片缩放就可以用PhotoView实现了。不足之处望多多指正!