0

I want to show a image in a activity . I successfully made it with imageview.But it has no zoom effect ie. I can't zoom the pic. now how can I add this zoom efect. my .xml code is :

 <ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"
    android:src="@drawable/cat" />
Sawpno
  • 85
  • 1
  • 2
  • 10

1 Answers1

1

use the lib https://github.com/chrisbanes/PhotoView

In code

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();
sasikumar
  • 12,540
  • 3
  • 28
  • 48
  • this library is good but I have some problem. some small images are displayed at the start of imageview.how can I solve this ?. I am using scale Type = centerinside. – Nabeel K Dec 08 '15 at 11:17