如何实现在android的图像视图缩放效果?缩放、视图、如何实现、图像

2023-09-12 10:52:37 作者:再玩lol我就拆你R键

我要实现的图像缩放,我已经试过有这么多的codes.But我没有得到的手势事件完全的想法。我想,当我们运用双击来实现,图像将放大根据触摸的地方(事件x和y)。我只需要实现缩放此时没有pan.Can任何机构给我建议?

I have to implement image zooming, I have tried with so many codes.But i didnt get full idea of gesture events. I want to implement when we apply double tap, image will be zooming according to the touch place(event x and y).I have to implement only zooming at this time no pan.Can any body suggest me ?

编辑:     其实我已经实现了与图像viewflipper,如果我尝试应用平移和缩放效果,有时图像将被改变。我要落实在用户点击的变焦效果。

Actually i have implemented that viewflipper with images, if i try to apply pan and zoom effect, sometimes images will be changed.I want to implement zoom effect for where the user is clicked.

给我的一些想法......

Give me some idea of that....

推荐答案

懒惰的人可以使用这个LIB ,只是内部导入项目

Lazy man can use this lib, Just import inside your project and

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();