An Instagram-like pinch-to-zoom Android ImageView with snap-back-to-original-position mechanism.
snapback_demo.mp4
Add the dependency below into your module's build.gradle file:
dependencies {
implementation "io.github.vanxioussss:snapback-image-view:<latest_version>"
}dependencies {
implementation("io.github.vanxioussss:snapback-image-view:<latest_version>")
}- Zoomable image views with pinch-to-zoom gestures.
- Snapback animation to return the image to its original position.
- Customizable attributes during zooming.
- Easy integration into existing projects. You just need to replace your current
ImageViewwithSnapbackImageView.
Add SnapbackImageView to your layout, or just replace your ImageView with SnapbackImageView:
<com.vanxiousss.snapback.SnapbackImageView
android:id="@+id/snapbackImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/sample_image"
app:shadowColor="#80000000"
app:shadowMaxAlpha="192"
app:shadowFadeEnabled="true"
app:minScaleFactor="1.0"
app:maxScaleFactor="5.0"
app:endAnimationEnabled="true"
app:endAnimationDuration="300" />You can customize the following attributes in XML:
shadowColor: The color of the shadow during zooming.shadowMaxAlpha: The maximum alpha value for the shadow.shadowFadeEnabled: Enable or disable shadow fading.minScaleFactor: The minimum scale factor for zooming.maxScaleFactor: The maximum scale factor for zooming.endAnimationEnabled: Enable or disable the snapback animation.endAnimationDuration: Duration of the snapback animation in milliseconds.
Copyright 2025 vanxioussss (Van Luong)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Contributions are welcome! Feel free to open issues or submit pull requests to improve the library.