Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zoom ImageView in android like Instagram

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.

like image 567
unos baghaii Avatar asked Jan 22 '17 20:01

unos baghaii


People also ask

How do you zoom in on a picture on android?

Tap anywhere on the screen, except the keyboard or navigation bar. Drag 2 fingers to move around the screen. Pinch with 2 fingers to adjust zoom. To stop magnification, use your magnification shortcut again.

What is pinch zoom in Android?

Pinch 2 or more fingers together or apart to adjust zoom. To zoom temporarily, quickly tap the screen 3 times and hold down your finger on the third tap. Drag your finger to move around the screen. Lift your finger to zoom out.

What is ImageView in Android?

Displays image resources, for example Bitmap or Drawable resources. ImageView is also commonly used to apply tints to an image and handle image scaling.


3 Answers

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();
like image 150
Ciro Mine Avatar answered Oct 22 '22 09:10

Ciro Mine


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.

like image 37
Anis LOUNIS Avatar answered Oct 22 '22 10:10

Anis LOUNIS


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);
like image 1
unos baghaii Avatar answered Oct 22 '22 09:10

unos baghaii