ImageViewZoom icon indicating copy to clipboard operation
ImageViewZoom copied to clipboard

Zoomed image plus ViewPage

Open xmenxwk opened this issue 12 years ago • 8 comments

Assume there are 2 images in a ViewPager and when zooming the first one and try to pan(drag), the parent viewpager scrolls to second image instead of image panning. Using this.getParent().requestDisallowInterceptTouchEvent(true); inside onTouchEvent of does the trick but where should I allow it. If you can update the code, it would be awesome. I'm new to android.

xmenxwk avatar Jul 25 '13 01:07 xmenxwk

You should extend the ImageViewZoom with your own ImageView subclass. Then try something like this:

this.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (getScale() > 1f) { getParent().requestDisallowInterceptTouchEvent(true); } else { getParent().requestDisallowInterceptTouchEvent(false); } return false; } });

This should basically disallow paging whenever the image is scaled/zoomed beyond 1x. Thus, the user must zoom out in order to page.

cargo8 avatar Jul 25 '13 07:07 cargo8

Thank you, thats a good idea, but is it possible to do without zoom out, I mean when it reaches the max bound, let the parent allow.

xmenxwk avatar Jul 25 '13 10:07 xmenxwk

Take a look at this:

http://stackoverflow.com/questions/14764603/how-to-intercept-touch-events-from-viewpager-onpagechangelistener

femosso avatar Jul 26 '13 12:07 femosso

@femosso : Thats not what I meant. How do I know user reached to max bound ?

xmenxwk avatar Jul 26 '13 18:07 xmenxwk

did you solve this problem , i have this too !

whgreate avatar Sep 11 '13 10:09 whgreate

Nope, I used the above method.

xmenxwk avatar Sep 11 '13 12:09 xmenxwk

I know this is a very old post but i couldnt find a solution else where other than this so if anyones der please respond.@cargo8 solution works fine but the getScale() method seems to be deprecated in the present versions of android. So i used getScaleFactor() method. But it returns value as 1.0 however your resize your image. How can we check the actual scale value of the image?

saishneugi avatar Jun 25 '15 05:06 saishneugi

Try this :

imageviewtouch.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) {

            switch (motionEvent.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    Log.d("touchme", "down");
                    view.getParent().requestDisallowInterceptTouchEvent(true);
                    //view.requestDisallowInterceptTouchEvent(true);
                    break;
                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_UP:
                    Log.d("touchme", "up");
                    view.getParent().requestDisallowInterceptTouchEvent(false);
                    //view.requestDisallowInterceptTouchEvent(false);
                    break;
                default:
                    break;
            }
            return false;
        }
    });

This will disable scrollview for taking touch event from imageviewtoich if the imageviewtouch still getting touch, will enable scroll on parent after imageviewtouch not receiving touch.

RaidenX5 avatar May 16 '19 02:05 RaidenX5