How can I get zoom functionality for images?

后端 未结 13 1196
粉色の甜心
粉色の甜心 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:34

    I just integrated Robert Foss's TouchImageView: it worked perfectly out of the box! Thanks!

    I just modified a bit the code so I could be able to instantiate it from my layout.xml.

    Just add two constructors

    public TouchImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }
    
    public TouchImageView(Context context) {
        super(context);
        init(context);
    }
    

    and transform the old constructor into an init method:

    private void init(Context context){
        //...old code ofconstructor of Robert Moss's code
    }
    

提交回复
热议问题