控件:photoView单点/多点触摸来进行图片缩放

版权声明:本文为博主原创文章,码字不易,转载时请标明具体出处(博主名+博客页面链接),万分感谢Thanks♪(・ω・)ノ https://blog.csdn.net/An_nAl/article/details/81064814

GitHub - chrisbanes/PhotoView: Implementation of ImageView for Android that supports zooming, by various touch gestures. https://github.com/chrisbanes/PhotoView

添加依赖

 repositories {
        maven { url "https://jitpack.io" }
    }

我的是compile 'com.android.support:appcompat-v7:26.+'但PhotoView自身包含的appcompat-v7与我的版本不一致。

compile ('com.github.chrisbanes:PhotoView:2.1.4'){
        exclude group: 'com.android.support', module: 'appcompat-v7'
    }

xml布局

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.github.chrisbanes.photoview.PhotoView
        android:id="@+id/photo_view"
        android:scaleType="centerCrop"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        android:src="@drawable/beauty1"/>
</android.support.constraint.ConstraintLayout>

activity

 PhotoViewAttacher mAttacher = new PhotoViewAttacher(photoView);
        mAttacher.setMaximumScale((float)6.0);

猜你喜欢

转载自blog.csdn.net/An_nAl/article/details/81064814