3

I have an activity that allows users to swipe between 3 different views. Each view displays a list of images. The images have onClick events that call a new activity and makes the images full screen. This all works ok however if I try to swipe between the 3 different views and my finger swipes over an image it will trigger the onClick event and open the image fullscreen. So I am wondering how can I put priority on onTouch (for the page/view swapping) ?

(the onTouch event uses a gestureListener and i'm using onFling and flipper methods..) (the onClick is simply a imageView.setOnClickListener(new OnClickListener() )

Mr X
  • 171
  • 1
  • 3
  • 7

2 Answers2

3

If you return true from your onFling(…) it should consume the event and stop propagation.

nEx.Software
  • 6,782
  • 1
  • 26
  • 34
  • Fantastic! That worked! It was such an obvious thing too that I wouldn't have noticed. Thanks a lot! – Mr X Nov 18 '11 at 15:46
0

You can find here solution for delegating a touch from parent to child view, if you need more info.

mDrawerLayout.post(() -> {
        Rect delegateArea = new Rect();

        mCalendarView.getHitRect(delegateArea);
        delegateArea.right += 100;
        delegateArea.bottom += 100;

        TouchDelegate touchDelegate = new TouchDelegate(delegateArea, mCalendarView);

        if (View.class.isInstance(mCalendarView.getParent())) {
            ((View) mCalendarView.getParent()).setTouchDelegate(touchDelegate);
        }
    });
ardiien
  • 767
  • 6
  • 26