我必须实现图像缩放,我尝试了很多代码。但我没有完全了解手势事件。我想在我们应用双击时实现,图像将根据触摸位置(事件 x 和 y)进行缩放。此时我只需要实现缩放,没有平移。任何人都可以建议我吗?
编辑: 实际上我已经用图像实现了那个viewflipper,如果我尝试应用平移和缩放效果,有时图像会被改变。我想在用户点击的地方实现缩放效果。
给我一些想法......
最佳答案
懒人可以用this lib , 只需在您的项目中导入并
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
mAttacher.update();
关于android - 如何在android中实现 ImageView 的缩放效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8399296/