Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.boycy815:PinchImageView:'
}
dependencies {
implementation("com.github.boycy815:PinchImageView:")
}
<dependency>
<groupId>com.github.boycy815</groupId>
<artifactId>PinchImageView</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.boycy815" % "PinchImageView" % ""
:dependencies [[com.github.boycy815/PinchImageView ""]]
English | 简体中文
A gesture-friendly and easy-to-use image pinch-zoom control. It extends ImageView
, is contained in a single class file, has no external dependencies, and is lightweight and easy to integrate.
1) Copy PinchImageView.java
into your project.
2) Add the following code to your layout file; it can already display an image from resources:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.boycy815.pinchimageview.PinchImageView
android:id="@+id/pic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/my_pic"/>
</RelativeLayout>
3) Use it directly as an ImageView
:
// Retrieve it as an ImageView
ImageView imageView = (ImageView) findViewById(R.id.pic);
// You can set the image using any method supported by ImageView
imageView.setImageResource(R.drawable.my_pic);
// or...
imageView.setImageBitmap(bitmap);
// or...
imageView.setImageDrawable(drawable);
// or you can even use third-party image loading libraries, like ImageLoader
imageLoader.displayImage("http://host.com/my_pic.jpg", imageView);