以下是我的方案:LinearLayout
作为Activity
的主要布局。布局包含ImageView
,其中有onClickListener
。
当用户将手指放在屏幕上时,触发ImageView
侦听器的最简单方法是什么。这是用户持有设备并错误地触摸屏幕(因此onTouch触发)但是想要按ImageView
的一般情况。在这种情况下,由于屏幕已被触摸,当按下ImageView
时,没有任何反应。
答案 0 :(得分:0)
我猜您可以使用 ACTION_DOWN & ACTION_POINTER_DOWN ,稍后进行第二次触摸。您需要在触摸列表器中处理这些事件。这个监听器可以在你的根布局上。
public boolean onTouchEvent(MotionEvent event) {
}
<强> See here, some excerpts are 强>
When multiple pointers touch the screen at the same time, the system generates the following touch events:
ACTION_DOWN—For the first pointer that touches the screen. This starts the gesture. The pointer data for this pointer is always at index 0 in the MotionEvent.
ACTION_POINTER_DOWN—For extra pointers that enter the screen beyond the first. The pointer data for this pointer is at the index returned by getActionIndex().
ACTION_MOVE—A change has happened during a press gesture.
ACTION_POINTER_UP—Sent when a non-primary pointer goes up.
ACTION_UP—Sent when the last pointer leaves the screen.