2012-04-03 34 views
0

我相信很多其他人在过去的某个地方会遇到这个问题。onTouchEvent()仅适用于空白空间?

我的main.xml被分为9 LinearLayouts与权重1和weightsum是9当然。 1布局充满空白空间。

我在我的活动中有一个onTouchEvent()函数,它的工作原理非常好。问题是触摸仅在空布局中被识别。其他布局充满了按钮和编辑文本和文字浏览。但触摸事件不起作用。我认为在调用onTouchEvent()之前调用按钮的“onClick”。

有什么办法可以使整个屏幕上的触摸工作?

我还没有提供任何代码,因为它是一个普通的问题,根据我不需要任何代码。 感谢您的期待。

回答

0

因为Activity doc说:当任何触摸事件发生在屏幕上的任何地方称为

onTouchEvent (MotionEvent event) Called when a touch screen event was not handled by any of the views under it. 
This is most useful to process touch events that happen outside of your window bounds, 
    where there is no view to receive it. 

onUserInteraction()方法。