添加依赖
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);