0

我有一个水平的 LinearLayout 和几个 ImageView。

我想在这些 ImageView 中滑动手指,并在每次手指进入和离开每个 ImageView 时收到回调。

我尝试了 onTouchListener、onHoverListener、onGenericMotionListener 的各种组合,但似乎最初按下的 ImageView 会“吃掉”这些动作。

如果它确实重要,我的视图结构如下所示:

ActionBar 有一个自定义视图:Horizo​​ntallScrollView -> LinearLayout -> ImageViews。

有任何想法吗?

4

1 回答 1

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

于 2013-10-27T16:11:48.700 回答