Android叠加层可吸引所有触控,并将其传递下去? [英] Android overlay to grab ALL touch, and pass them on?

查看:132
本文介绍了Android叠加层可吸引所有触控,并将其传递下去?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上是试图从诸如系统覆盖之类的东西中获取所有触摸事件数据,基于此触摸数据来移动精灵,然后允许OS/主屏幕/浏览器按应有的方式对数据进行操作(或反之)反之亦然).我发现了类似的问题,但没有任何东西可以将我引向任何尚未出现的地方:

I'm basically trying to get all touch event data from something like a system overlay, move my sprites around based on this touch data, then allow the OS/homescreen/browser to act upon the data as it should(or vice versa). I have found similar questions, but nothing that leads me anywhere I haven't already been:

获取正在接受所有触摸的视图事件

(已实现,结果如下) 创建系统覆盖窗口(始终在顶部)

(Implemented, with results below) Creating a system overlay window (always on top)

我可以做什么:

我可以捕获所有触摸事件并通过移动精灵来对其进行操作,并且不允许OS/主屏幕/浏览器看到它们中的任何一个,否则,我可以允许触摸事件通过并仅获得"TOUCH_OUTSIDE"供我的应用执行.

I can EITHER grab ALL the touch events and act upon them by moving my sprites and not allow the OS/homescreen/browser to see any of them, OR ELSE I can allow the touch events to pass through and only get a "TOUCH_OUTSIDE" for my app to act upon.

我未达到的目标:

我终生无法找到使两者都可以处理数据的方法.我能想到的唯一无法实现的方法是: 拦截我APP中的数据,并将其传递到OS/主屏幕/浏览器以进行处理 允许OS/主屏幕/浏览器先获取数据,然后以某种方式获取包含信息的回调 允许OS/主屏幕/浏览器获取数据,对数据进行操作并对其滚动/位置值进行轮询,以便在我的APP中对其进行操作.

I CAN NOT for the life of me figure out a way around getting BOTH to work with the data. The only methods I can think of, that I can't get implemented are: Intercepting the data in my APP and passing it onto OS/homescreen/browser to work with Allowing the OS/homescreen/browser to get the data first, and then getting a callback with information somehow Allowing the OS/homescreen/browser to get the data, act on the data, and the poll them for what their scroll/location values are so as to act upon it in my APP.

我担心这是不可能的,我想我读了一些现在找不到的文档: 全部或全无,要么您的视图获取所有事件,要么全都没有"

I fear that this just isn't possible, I think I read somewhere in some documentation that I can't find now: "It's all or nothing, either your view gets all the events, or none of them"

(为避免混淆,我并不是说我有两个视图.我是说我有一个视图是通过活动/服务覆盖OS/主屏幕/浏览器来控制的.如果可以的话,就像一块玻璃一样.)

(To avoid confusion, I don't mean I have two views. I mean I have one view controlled via activity/service overlaying the OS/homescreen/browser. Like a pane of glass if you will.)

感谢您提供的任何有用信息,非常感谢!

Thank you for any helpful information you can offer, it's very much appreciated!

[更新] 在下面的问题上发布了我自己的文档,以免引起混淆.

[UPDATE] Posted my own documentation on the matter below, so as to not be confusing.

推荐答案

发现此文档几乎指出不可能同时执行以下操作: Android:多点触摸和TYPE_SYSTEM_OVERLAY

Found this documentation that pretty much states that it's not possible to do both: Android : Multi touch and TYPE_SYSTEM_OVERLAY

他们讨论了变通办法,但我认为它们中的任何一个都不能真正按照我的意图进行工作.两者都将事件提供给了底层的应用程序,并能够窥探到它们以自己采取行动.

They discuss workarounds but I don't think any of them will actually work for exactly what I'm trying to do. Both given the events to the underlying app, and being able to snoop them to act upon them for myself.

要创建覆盖视图,请在设置LayoutParams时需要 将类型设置为TYPE_SYSTEM_OVERLAY并使用标志 FLAG_WATCH_OUTSIDE_TOUCH.这就提出了一个问题,因为 Android文档指出:您将不会收到完整的 向下/移动/向上手势,仅将第一个向下的位置作为 ACTION_OUTSIDE."以接收完整的触摸事件 您需要使用TYPE_SYSTEM_ALERT类型,但这会导致 覆盖以接管屏幕并停止与其他屏幕的交互 元素.

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.

任何人都不同意我想听到好消息:-D

Anyone wants to disagree I'd love to hear good news :-D

这篇关于Android叠加层可吸引所有触控,并将其传递下去?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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