Zoomy is an easy to use pinch-to-zoom Android library

Overview

Maven Central

Zoomy

Zoomy is an easy to use pinch-to-zoom Android library

alt tag

Installation

implementation 'io.github.imablanco:zoomy:{latest version}'

Usage

To start using Zoomy, just register the View you want to be zoomable

Zoomy.Builder builder = new Zoomy.Builder(this).target(mZoomableView);
builder.register();
            

Thats all. Now your views can be pinch-zoomed!

Views can be unregistered for Zoomy too

Zoomy.unregister(mZoomableView');
            

Customization

Zoomy allows a few customizations in its behavior:

  • Use ZoomyConfig to change default configuration flags
ZoomyConfig config = new ZoomyConfig();
config.setZoomAnimationEnabled(false); //Enables zoom out animation when view is released (true by default)
config.setImmersiveModeEnabled(false); //Enables entering in inmersive mode when zooming a view (true by default)          
  • Now set this as the default configuration across all Zoomy registered views
Zoomy.setDefaultConfig(config);           

Zoomy builder also allows some customization

  • Zoomy config flags can also be set when building Zoomy registration. This flags will always override default ZoomyConfig flags.
    Zoomy.Builder builder = new Zoomy.Builder(this)
                    .target(mZoomableView)
                    .enableImmersiveMode(false)
                    .animateZooming(false);
  • You can add callbacks to listen for specific events. Because Zoomy works by attaching a View.OnTouchListener to the registered View, View.OnClickListener can not be set along with Zoomy, so a TapListener, LongPressListener and DoubleTapListener are provided to ensure the View still can listen for gestures. A ZoomListener is also provided if you are interested in zoom events.
 Zoomy.Builder builder = new Zoomy.Builder(this)
                    .target(mZoomableView)
                    .tapListener(new TapListener() {
                        @Override
                        public void onTap(View v) {
                            //View tapped, do stuff
                        }
                    })
                     .longPressListener(new LongPressListener() {
                        @Override
                        public void onLongPress(View v) {
                            //View long pressed, do stuff
                        }
                    }).doubleTapListener(new DoubleTapListener() {
                        @Override
                        public void onDoubleTap(View v) {
                            //View double tapped, do stuff
                        }
                    })
                    .zoomListener(new ZoomListener() {
                        @Override
                        public void onViewStartedZooming(View view) {
                            //View started zooming
                        }

                        @Override
                        public void onViewEndedZooming(View view) {
                            //View ended zooming
                        }
                    });        
  • It is possible to change the interpolator used when animating ending zoom event.
   Zoomy.Builder builder = new Zoomy.Builder(this)
                    .target(mZoomableView)
                    .interpolator(new OvershootInterpolator());

License

Copyright 2017 Álvaro Blanco Cabrero
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.
Comments
  • White background on status bar and nav buttons

    White background on status bar and nav buttons

    When I zoom in on a photo (Nexus 5X, Android 6.0), I notice the background where the nav buttons and the status bar are turn white. Fitting with the rest of the background, it would be nice if they turned black instead.

    Is there any way we can customize this feature?

    screenshot_20180307-095551

    opened by AdamMc331 9
  • Could not apply zoomy inside an adapter

    Could not apply zoomy inside an adapter

    I tried implementing zoomy using the documentation and for some reason, I can't implement it inside an adapter, am I doing some error here?

     Zoomy.Builder builder = new Zoomy.Builder(AdvancedItemListAdapter.this)
                        .target(holder.mItemImg);
                builder.register();
    
    
    opened by snajdovski 2
  • 3fingers screenshot fix

    3fingers screenshot fix

    Problem

    After screenshot gesture, zoom not working anymore See https://github.com/imablanco/Zoomy/issues/19

    Solution

    • Listen for touch events on decorView and forward them to target view
    opened by kristiyanP 2
  • How can i add onLongPress Listener

    How can i add onLongPress Listener

    Hello there, There is no method to detect if user has long pressed on image, so how can I add onDoubleTap and onLongClick Listener to view ...pls help me.....

    opened by ervinod 2
  • hold zoom level

    hold zoom level

    when an image is zoomed and the finger is lifted it comes to the initial state. I want to keep that at the level and come back to the initial state on double-tap. how to do that?

    opened by sagarnayak 1
  • Disable click during zooming

    Disable click during zooming

    Hi, I noticed that the views in the background are still receiving click and touch events during zooming. Would be nice to have the option to disable background touch/click events during zooming.

    opened by katie-cb 1
  • Zoomy in RecyclerView

    Zoomy in RecyclerView

    Hello guys,

    Can you please explain how I can unregister zoomy from a view in RecyclerView? the problem is that I have many types of view, on some of them I want to be able to apply zoom and on some I don't. Because the recycling mechanism I'm getting zooming ability on views that I don't want.

    opened by nativ18 1
  • Allow backup should not be set in a library

    Allow backup should not be set in a library

    #Problem In the AndroidManifest.xml android:allowBackup="true" should not be set, it should be the application that decides and not the library

    More info on why is a bad practice

    https://github.com/AzureAD/azure-activedirectory-library-for-android/issues/472 https://github.com/realm/realm-java/issues/2227

    opened by kristiyanP 0
  • Cannot set 'scaleX' to Float.NaN, Fatal Exception: java.lang.IllegalArgumentException

    Cannot set 'scaleX' to Float.NaN, Fatal Exception: java.lang.IllegalArgumentException

    Hi, I'm seeing this crash for some users(affects ~0.01%), all of them on android 10.

    Any idea what it might be, or how to work around it?

    This is all the code, not using any additional features of the library:

    <ImageView
       android:id="@+id/imageView"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:adjustViewBounds="true"
       android:animateLayoutChanges="true"
       android:scaleType="centerCrop"
       android:src="@drawable/img" />
    
    Picasso.get()
        .load(imageUrl)
        .error(R.drawable.img)
        .placeholder(R.drawable.img)
        .into(imageView)
    
    Zoomy.Builder = Zoomy.Builder(this).target(imageView)
    builder.register()
    

    Exception:

    Fatal Exception: java.lang.IllegalArgumentException
    Cannot set 'scaleX' to Float.NaN
    android.view.View.sanitizeFloatPropertyValue (View.java:18167)
    android.view.View.sanitizeFloatPropertyValue (View.java:18141)
    android.view.View.setScaleX (View.java:17494)
    com.ablanco.zoomy.ZoomableTouchListener.onScale (ZoomableTouchListener.java:223)
    android.view.ScaleGestureDetector.onTouchEvent (ScaleGestureDetector.java:376)
    com.ablanco.zoomy.ZoomableTouchListener.onTouch (ZoomableTouchListener.java:112)
    android.view.View.dispatchTouchEvent (View.java:14372)
    android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
    android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
    android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
    android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
    android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
    android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
    android.widget.ScrollView.dispatchTouchEvent (ScrollView.java:857)
    android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
    android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
    android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
    android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
    android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
    android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
    android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
    android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
    android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
    android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
    android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3863)
    android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:3551)
    com.android.internal.policy.DecorView.superDispatchTouchEvent (DecorView.java:733)
    com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1922)
    android.app.Activity.dispatchTouchEvent (Activity.java:4051)
    androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:69)
    androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:69)
    com.android.internal.policy.DecorView.dispatchTouchEvent (DecorView.java:691)
    android.view.View.dispatchPointerEvent (View.java:14644)
    android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:6526)
    android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:6313)
    android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5751)
    android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:5804)
    android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:5770)
    android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:5926)
    android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:5778)
    android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:5983)
    android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5751)
    android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:5804)
    android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:5770)
    android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:5778)
    android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5751)
    android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:8910)
    android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:8771)
    android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:8724)
    android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:9046)
    android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:194)
    android.view.InputEventReceiver.nativeConsumeBatchedInputEvents (InputEventReceiver.java)
    android.view.InputEventReceiver.consumeBatchedInputEvents (InputEventReceiver.java:183)
    android.view.ViewRootImpl.doConsumeBatchedInput (ViewRootImpl.java:8986)
    android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run (ViewRootImpl.java:9073)
    android.view.Choreographer$CallbackRecord.run (Choreographer.java:996)
    android.view.Choreographer.doCallbacks (Choreographer.java:794)
    android.view.Choreographer.doFrame (Choreographer.java:722)
    android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:981)
    android.os.Handler.handleCallback (Handler.java:883)
    android.os.Handler.dispatchMessage (Handler.java:100)
    android.os.Looper.loop (Looper.java:237)
    android.app.ActivityThread.main (ActivityThread.java:7948)
    java.lang.reflect.Method.invoke (Method.java)
    com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
    com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1075)
    
    opened by TorkelV 0
  • Hi

    Hi

    it is zooming only center of picture. it is not zooming the area of fingers coordinate on picture. is this possible to zooming finger coordinate area? Thank you

    opened by alikemalben 0
  • Android 10 horrible bug D:

    Android 10 horrible bug D:

    Hello sir, in android 10 there the images can't stay in their border

    eg: WhatsApp Image 2020-06-25 at 13 42 28

    I'm in a recyclerView in adapter class that where I'm doing the work :

    `
    Glide.with(holder.imageView.context).load(currentItem.imageResource).into(holder.imageView)

        Zoom(holder.imageView)
    
        holder.textView1.text = currentItem.text1
    
        holder.textView2.text = currentItem.text2`
    
    opened by ghost 2
  • onViewBeforeStartedZooming Callback

    onViewBeforeStartedZooming Callback

    As part of the zoomListener - it's a callback that's called before zooming starts. This is useful in cases we want to manipulate the image/view being displayed, before the zooming starts.

    For example - ImageView with a center-crop scale type, that we want to show fully (fit-center) when zooming in.

    opened by budowski 3
Owner
Álvaro Blanco
Álvaro Blanco
Tutorial Double Tap Pinch to Zoom with kotlin

Double-Tap-Pinch-Zoom Tutorial Double Tap Pinch to Zoom Tutorial Build with Andr

Azhar Rivaldi 6 Apr 13, 2022
PinchToZoom - Pinch to zoom used within list like Instagram

Pinch To Zoom ?? Description Pinch to Zoom with Pan Gestures like Instagram ?? Motivation and Context Big Thanks ???? to the guy and his amazing repo

Vivek Sharma 12 Apr 12, 2022
Android library (AAR). Highly configurable, easily extendable deep zoom view for displaying huge images without loss of detail. Perfect for photo galleries, maps, building plans etc.

Subsampling Scale Image View A custom image view for Android, designed for photo galleries and displaying huge images (e.g. maps and building plans) w

null 7.4k Jan 8, 2023
Android ImageView widget with zoom and pan capabilities

ImageViewTouch for Android ImageViewTouch is an android ImageView widget with zoom and pan capabilities. This is an implementation of the ImageView wi

Alessandro Crugnola 1.9k Jan 4, 2023
Slider-Gallery-Zoom: image slider for android supporting indicator and auto scroll with clicking on image

image slider supporting indicator and auto scroll with clicking on image to open full screen image slider swipe and pinch zoom gestures like gallery,just pass your images and the position of the current image.

Mahmoud Elian 3 May 28, 2022
Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling Scale Image View, Fresco, Glide, and Picasso. Even with gif and webp support! 🍻

BigImageViewer Big image viewer supporting pan and zoom, with very little memory usage and full featured image loading choices. Powered by Subsampling

Piasy 3.9k Dec 30, 2022
Android library to generate image avatar from the first letter of a username. Letter avatar like Gmail Android best practice

AvatarImageGenerator Generate first letter avatar Image like gmail's contact avatar. It generates an drawable that can be be set to an ImageView. Inst

Korir Amos 61 Sep 25, 2022
Android library project for cropping images

I guess people are just cropping out all the sadness An Android library project that provides a simple image cropping Activity, based on code from AOS

Jamie McDonald 4.5k Dec 29, 2022
An open source Android library that allows the visualization of large images with gesture capabilities

ByakuGallery ByakuGallery is an open source Android library that allows the visualization of large images with gesture capabilities. This lib is based

Diego Lima 311 Dec 4, 2022
Android library written in kotlin that add a noise effect to image.

NoiseView With NoiseView you can easily add a noise effect to your image. See demo on YouTube Setup The library is pushed to jCenter() as an AAR, so y

Przemek 46 Sep 8, 2022
This is a library for make auto slide image in android

Auto Image Slider Screenshot Image Slider Default Image Slider With Custom Adapter Usage Add ImageSlider to your layout

Afdhal_FA 17 Dec 1, 2022
Android Blurred ImageSwitcher Library

Android Blurred ImageSwitcher Library

Chrisvin Jem 48 Jul 2, 2022
Android Library for cropping an image at ease.

Cropper - Android Image Cropper Android Image Cropper Powerful (Zoom, Rotation, Multi-Source); Customizable (Shape, Limits, Style); Optimized (Async,

Akshat Tiwari 24 Aug 24, 2022
A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows

A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows.Provides fast canvas draw as no renderscript needed .The similar shadow blurred effects can also be seen in iOS Music App.

Vivek Verma 163 Dec 31, 2022
Custom ImageView for android with polygon shape (Android)

PolygonImageView Create a custom ImageView with polygonal forms. Usage To use PolygonImageView, add the module into your project and start to build xm

Albert Grobas 531 Dec 25, 2022
Implementation of ImageView for Android that supports zooming, by various touch gestures.

PhotoView PhotoView aims to help produce an easily usable implementation of a zooming Android ImageView. [ Dependency Add this in your root build.grad

Baseflow 18.4k Dec 30, 2022
A circular ImageView for Android

CircleImageView A fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi which itself is based on techniq

Henning Dodenhof 13.8k Mar 29, 2021
Android filters based on OpenGL (idea from GPUImage for iOS)

GPUImage for Android Idea from: iOS GPUImage framework Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are e

CATS Open Source Softwares 8.6k Jan 8, 2023