Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

is it possible to set some kind of onScale/ZoomListener ? #71

Open
osemen-remit opened this issue May 13, 2015 · 6 comments
Open

is it possible to set some kind of onScale/ZoomListener ? #71

osemen-remit opened this issue May 13, 2015 · 6 comments

Comments

@osemen-remit
Copy link

Hi,
I would like to hide some controls when user starts zooming/scaling and show them back when image fits screen. So I'm wondering if there is a possibility to set some kind of listener.
So far as I can see there is something like this but it is private...
Any suggestions ?
Thanks.

@cargo8
Copy link

cargo8 commented May 13, 2015

This should work. Also might want to setMaxScale and setMinScale

imageView.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (getScale() > 1f) {
                    // Do stuff at > 1x scale
                    return true;
                } else if (getScale() < 1f) {
                    // Do stuff at < 1x scale
                    return true;
                }
                return false;
            }
        });

@osemen-remit
Copy link
Author

thanks @cargo8
btw return true; prevent image of scaling

any way it would be nice to have some listener for this purpose.

@mdwem
Copy link

mdwem commented Jul 21, 2015

I am trying to do something similar and returns true prevents scaling.Is there any other way to get these values

@osemen-remit
Copy link
Author

return false

@mdwem
Copy link

mdwem commented Jul 23, 2015

Thanks,got it working.I have a method
myImageView.setOnTouchListener(new View.OnTouchListener() {
@OverRide
public boolean onTouch(View v, MotionEvent event) {

            Log.i(LOG_TAG,"x =  " + String.valueOf(event.getX()));

            Log.i(LOG_TAG, "y =  " + String.valueOf(event.getY())); 
          return false

}
When the image is scaled,how do i maintain the coordinate position of (x,y) with respect to the image.

@osemen-remit
Copy link
Author

Common approach is to multiply point of original image by the transformation matrix of image in order to get position of resulting point.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants