Zoom ImageView in android like Instagram

10,828

Solution 1

I would recommend these two libraries:

  1. PhotoView

  2. ImageViewZoom

For PhotoView, you just have to create an attacher and "attach" it to your ImageView.

Some code

// After getting your imageImage view, attach it like the following
PhotoViewAttacher yourAttacher = new PhotoViewAttacher(yourImageView);

With just this code, you'll be able to zoom in/out/whatever on yourImageView. Check the links above for more details.

EDIT

Instagram has changed a lot since this answer was posted, and the libraries I recommended above might not provide the experience you are looking for.

Solution 2

I recommend Zoomy, very simple and functional.

Just add the following to your current ImageView:

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

Solution 3

thanks

I have added this to my gradle.build

 compile 'it.sephiroth.android.library.imagezoom:imagezoom:2.2.5'

and then using this view

  <it.sephiroth.android.library.imagezoom.ImageViewTouch
    android:id="@+id/mp3Image"
    android:adjustViewBounds="true"
    android:layout_width="346dp"
    android:layout_height="356dp"
    android:scaleType="fitCenter" />

and the below code, the zoom came to my app

   myImage = (ImageViewTouch) findViewById(R.id.mp3Image);
    myImage.setDisplayType(ImageViewTouchBase.DisplayType.FIT_IF_BIGGER);
Share:
10,828
unos baghaii
Author by

unos baghaii

Updated on June 08, 2022

Comments

  • unos baghaii
    unos baghaii almost 2 years

    How can I zoom ImageView like Instagram. I mean changing the size of imageview, not zooming the image inside the Imageview.

    For zooming the image inside the Imageview, there are a lot of samples but I want something like Instagram image zooming

    Any code or hint? Thanks.

  • AdamMc331
    AdamMc331 about 6 years
    Zoomy is very nice! It supports zooming, resetting, and has callbacks for when zoom starts/ends. This is something that was missing from a few of the other libraries mentioned.
  • MohammedAli
    MohammedAli over 5 years
    i can used your posted libraries, but still zoom within imageview not like instagram..
  • Tigran Babajanyan
    Tigran Babajanyan almost 5 years
    Also it's great that it allows to add interpolators thoughtbot.com/blog/android-interpolators-a-visual-guide
  • Tigran Babajanyan
    Tigran Babajanyan almost 5 years
    How to disable automatic zoom out
  • Anis LOUNIS aka AnixPasBesoin
    Anis LOUNIS aka AnixPasBesoin almost 3 years
    @MDKhali things might have changed since I initially posted this answer.
  • Lukas Niessen
    Lukas Niessen over 2 years
    To import: implementation 'com.ablanco.zoomy:zoomy:1.1.0' (On GitHub the link to the latest version is dead, the latest version is 1.1.0)