0

I have a horizontal LinearLayout and a couple of ImageViews in it.

I would like to swipe my finger through these ImageViews and receive a callback every time my finger enters and leaves each ImageView.

I tried various combinations of onTouchListener, onHoverListener, onGenericMotionListener but it seems that the ImageView that has been pressed initially "eats" these actions.

If it does matter my view structure is as simple as following:

ActionBar has a custom view: HorizontallScrollView -> LinearLayout -> ImageViews.

Any ideas?

lgasior
  • 310
  • 1
  • 3
  • 11

1 Answers1

0

Basically touch event finds the deepest view at the touch event.

SO, yes view structure totally matters.

To stop the child view to receive touchevent,

override onInterceptTouchEvent in your parents' view which is LinearLayout

What happens is:

-child gets action cancel event

-parent get the event trough onTouch

If you don't want the parents to intercept touchEvents anymore, override requestDisallowInterceptTouchEvent

Commuze
  • 25
  • 5
  • Thanks for your replay. I finally implemented this by setting onTouch on parent container and then checking for specific view like in this answer: http://stackoverflow.com/a/4692133/2873727 – lgasior Oct 27 '13 at 20:27