检查是否执行了MotionEvent.ACTION_MOVE

时间:2011-01-12 22:05:09

标签: android opengl-es motion-detection

我在opengl ES中制作一个带有叠加效果的按钮,就像谷歌地图一样;我希望我的按钮在击中时显示叠加,并在再次击中按钮时将其关闭。问题是如果用户按下按钮并拖动图像,则覆盖仍然会关闭。有没有办法确定在活动过程中是否执行了ACTION_MOVE?这样我可以将其设置为仅在未检测到ACTION_MOVE时关闭/打开。感谢。

1 个答案:

答案 0 :(得分:1)

如果我理解,你可以像这样设置按钮:

 public void onTouch(View args, MotionEvent ev) {
      if (ev.getAction() == MotionEvent.ACTION_DOWN) doButtonStuff();
      if (ev.getAction() == MotionEvent.ACTION_UP) doOtherButtonStuff();
 }

只需使用触控侦听器,而非点击侦听器。

〜Aedon