获取与WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH所有MotionEvents [英] Getting all MotionEvents with WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH

查看:2314
本文介绍了获取与WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH所有MotionEvents的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是指直接向这个问题。在回答这个问题说明了如何可以创建一个的ViewGroup ,将其嵌入在窗口管理器,并允许窗口管理器 MotionEvent 取值通过的onTouchEvent(MotionEvent事件) WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH 是允许将此这种的ViewGroup 收到 MotionEvent 秒。然而,根据文献,该标志

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 MotionEvents through onTouchEvent(MotionEvent event). WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH is the flag that allows this this ViewGroup to receive MotionEvents. However, according to documentation, this flag

...不会收到完整的向下/移动/向上的姿态

...will not receive the full down/move/up gesture

我想知道,如果有一个解决方法或途径,这样我可以得到所有的触摸事件,包括向下,移动和向上。概念验证是在应用程序波发射这使用相同的概念,但能够获得的不仅仅是一个单一的 ACTION_OUTSIDE 事件。

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.

推荐答案

我意识到这是一个老问题,但我已经通过它跌跌撞撞,而试图完成类似的东西。我也发现了这一点,希望这是有帮助的人: 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/

要创建一个覆盖视图​​,设置您需要的LayoutParams时   设置的类型TYPE_SYSTEM_OVERLAY并使用该标志   FLAG_WATCH_OUTSIDE_TOUCH。这presents一个问题,因为作为   Android的文件指出:你会不会收到完整的   向下/移动/手势,第一只位置向下作为   ACTION_OUTSIDE。为了接收触摸事件的全阵列   您需要使用TYPE_SYSTEM_ALERT类型,但是这会导致   覆盖接管屏幕并停止互动与其他   元素。的解决方案是使用两个TYPE_SYSTEM_OVERLAY和   TYPE_SYSTEM_ALERT和它们之间的切换通过改变类型   根据需要的LayoutParams。

To create an overlay view, when setting up the LayoutParams you need to set the type to TYPE_SYSTEM_OVERLAY and use the flag FLAG_WATCH_OUTSIDE_TOUCH. This presents a problem because as the Android documentation states: "you will not receive the full down/move/up gesture, only the location of the first down as an ACTION_OUTSIDE." In order to receive the full array of touch events you need to use the TYPE_SYSTEM_ALERT type, but this causes the overlay to take over the screen and stop interaction with other elements. The solution is to use both TYPE_SYSTEM_OVERLAY and TYPE_SYSTEM_ALERT and switch between them by changing the type of the LayoutParams as needed.

这篇关于获取与WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH所有MotionEvents的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆