How can I get zoom functionality for images?

后端 未结 13 1341
粉色の甜心
粉色の甜心 2020-11-22 02:13

Is there a common way to show a big image and enable the user to zoom in and out and pan the image?

Until now I found two ways:

  1. overwriting ImageView,
13条回答
  •  耶瑟儿~
    2020-11-22 02:31

    You can try using the LayoutParams for this

    public void zoom(boolean flag){
        if(flag){
            int width=40;
            int height=40;
        }
        else{
            int width=20;
            int height=20;
        }
        RelativeLayout.LayoutParams param=new RelativeLayout.LayoutParams(width,height); //use the parent layout of the ImageView;
        imageView.setLayoutParams(param); //imageView is the view which needs zooming.
    }
    

    ZoomIn = zoom(true); ZoomOut = zoom(false);

提交回复
热议问题