2

In my application I have a custom View (that extends ImageView) and in it we handle the touch events to move Image.

Then I make ViewPager to slide right or left to show the next layout.

The custom View onTouchEvent code works fine by itself. The ViewPager code also works fine. However, if I add them both, my custom View code for move image left or right stops working.

Here's the code for the OnTouchEvent in the custom View:

@Override
public boolean onTouchEvent(MotionEvent event) {
    super.onTouchEvent(event);

    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        //TODO
        break;
    case MotionEvent.ACTION_MOVE:
        //TODO
        break;
    case MotionEvent.ACTION_UP:
        //TODO
        break;
    }
    return true;
}

Hoping for any help!!!!!

nidhi_adiga
  • 1,114
  • 1
  • 16
  • 27
MayBreath
  • 33
  • 1
  • 3

1 Answers1

0

Please check this post:

android: ViewPager and HorizontalScrollVIew

there are a couple of solution how to handle situation when the ViewPager contents is also scroll-able.

you will have to create your own custom ViewPager and override the onInterceptTouchEvent method.

Community
  • 1
  • 1
Emil Adz
  • 40,709
  • 36
  • 140
  • 187