添加了一个不覆盖所有布局的 spaceView。我希望手势检测仅适用于该 View 。
不能做太多,但这是我的代码:
space = findViewById(R.id.space);
this.gDetector = new GestureDetectorCompat(this, this);
gDetector.setOnDoubleTapListener(this);
最佳答案
Android 中的 onTouchEvent
可让您这样做。您可以在该事件中添加任何您想做的事情。
根据 Android Studio 的官方网站,onTouchEvent()
被描述为 ...
当用户将一根或多根手指放在屏幕上时,这会在接收到触摸事件的 View 上触发回调 onTouchEvent()。对于最终被识别为手势的每个触摸事件序列(位置、压力、大小、添加另一个手指等),都会触发多次 onTouchEvent()。
Here's为您提供进一步帮助的官方链接
希望这有助于...
关于java - 特定 View 的手势检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52236969/