How to zoom in to a View image?

Asked

Viewed 411 times

3

I am looking for the implementation of a zoom on the internet but do not think. I found just a zoom that is applied across the image. I needed this default zoom that you have in most apps that allows you to zoom in on any point of the image. Does anyone know how to implement this? Thank you in advance.

1 answer

3

Look there’s this lib here

ImageView mImageView;
PhotoViewAttacher mAttacher;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Any implementation of ImageView can be used!
    mImageView = (ImageView) findViewById(R.id.iv_photo);

    // Set the Drawable displayed
    Drawable bitmap = getResources().getDrawable(R.drawable.wallpaper);
    mImageView.setImageDrawable(bitmap);

    // Attach a PhotoViewAttacher, which takes care of all of the zooming functionality.
    mAttacher = new PhotoViewAttacher(mImageView);
}


// If you later call mImageView.setImageDrawable/setImageBitmap/setImageResource/etc then you just need to call
attacher.update();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.