你需要这样:
步骤 1. 将 JitPack 存储库添加到您的构建文件中将其添加到存储库末尾的根 build.gradle 中:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
步骤 2. 添加依赖项
dependencies {
implementation 'com.github.sheetalkumar105:ZoomImageView-android:1.01'
}
步骤 3. 在布局中添加 ZoomImageView
<com.impulsive.zoomimageview.ZoomImageView
android:layout_width="match_parent"
android:layout_height="300dp"
android:src="@drawable/sample"
android:scaleType="matrix"
app:rotation="true"
app:scaledown="true"
/>
app:rotation="true" // Allow to rotate image in view. Default value is true.
app:scaledown="true" // Allow to ZoomOut less than container size. Default value is false.
完整代码:
https://github.com/sheetalkumar105/ZoomImageView-android/blob/master/zoomimageview/src/main/java/com/impulsive/zoomimageview/ZoomImageView.java