使用 WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH 获取所有 MotionEvent
我的问题直接涉及这个问题。该问题的答案展示了如何创建一个 ViewGroup,将其嵌入到 WindowManager 中,并允许 WindowManager 捕获 MotionEvent 通过onTouchEvent(MotionEvent event)
。 WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
是允许此 ViewGroup
接收 MotionEvent
的标志。然而,根据文档,这个标志
...不会收到完整的向下/移动/向上手势
我想知道是否有解决方法或方法,以便我可以获得所有触摸事件,包括向下、移动和向上。概念验证位于应用Wave Launcher中它使用相同的概念,但能够接收多个 ACTION_OUTSIDE
事件。
My question refers directly to this question. The answer to that question shows how one can create a ViewGroup
, embed it inside a WindowManager
, and allow the WindowManager
to catch MotionEvent
s through onTouchEvent(MotionEvent event)
. WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
is the flag that allows this this ViewGroup
to receive MotionEvent
s. However, according to documentation, this flag
...will not receive the full down/move/up gesture
I want to know if there's a work-around or a way so that I can get all touch events including down, move, and up. A proof of concept is in the app Wave Launcher which uses the same concept but is able to receive more than just a single ACTION_OUTSIDE
event.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我意识到这是一个老问题,但我在尝试完成类似的事情时偶然发现了它。我也发现了这个,希望对某人有帮助: http://www.section465.com/code_OverlayView/
I realize this is an old question, but I've stumbled across it while trying to accomplish something similar. I've also found this, hopefully it is helpful to someone: http://www.section465.com/code_OverlayView/
不,你不能,这很大程度上是设计使然。
Wave Launcher 不会这样做,它有一个 UI 元素,您可以在其中启动触摸手势,然后与标准一样,甚至分派所有触摸事件都会传递到第一个向下点的窗口,直到最后向上。
No you can not, and that is very much by design.
Wave Launcher doesn't do this, it has a UI element where you start your touch gesture and then as with standard even dispatching all touch events are delivered to the window of the first down point until the final up.