将窗口叠加层上的触摸事件传递到其后面的活动 [英] Pass through touch events on window overlay to an Activity behind it

查看:199
本文介绍了将窗口叠加层上的触摸事件传递到其后面的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些上下文.
我有一个与WindowManager一起添加的RelativeLayout,类型为TYPE_SISTEM_ALERT,带有标志FLAG_NOT_TOUCH_MODAL FLAG_WATCH_OUTSIDE_TOUCH.
我可以在此RelativeLayout上或其后面"的活动中获得触摸事件,但只要它不属于添加的"RelativeLayout窗口"的一部分即可.

Some context.
I have a RelativeLayout that is added with a WindowManager the type is TYPE_SISTEM_ALERT with the flags FLAG_NOT_TOUCH_MODAL FLAG_WATCH_OUTSIDE_TOUCH.
I'm able to get touch events either on this RelativeLayout or in the Activity "behind" it, but as long as it's not part of the "RelativeLayout window" added.

*黑条是我的RelativeLayout上的视图";
*红色矩形是此RelativeLayout的整个容器;
*黄色的星星是从黑色的视图中创建的空间点;
*空格是此RelativeLayout窗口顶部的Activity.

* The black bars are the Views on my RelativeLayout;
* the red rectangle is the whole container of this RelativeLayout;
* the yellow stars are the spots of space that is created from the black views;
* the white space is the Activity behind this RelativeLayout window on top.

想象一下,在活动A的黄色星星点上有一个Button,但是用户单击该按钮就可以看到.
即使活动A的按钮位于"此RelativeLayout窗口的后面,该按钮也应该能够响应.

Imagine there is a Button on the yellow stars spots that are from the Activity A, BUT are VISIBLE to the user and if he clicks there.
the Button of the Activity A should be able to respond, even though its "behind" this RelativeLayout Window.

我的参考,但不幸的是到目前为止没有成功:

My references, but unfortunately without success so far are :

  1. Android叠加层可抓取所有触摸并传递他们在吗?
  2. Android:多点触摸和TYPE_SYSTEM_OVERLAY
  1. Android overlay to grab ALL touch, and pass them on?
  2. Android : Multi touch and TYPE_SYSTEM_OVERLAY

是否有解决方法?

推荐答案

是否有解决方法?

Is there a workaround to this?

如果所讨论的活动是您自己的活动,请摆脱系统级覆盖,并在活动自己的视图层次结构中实现该覆盖.

If the activity in question is your own activity, get rid of the system-level overlay and implement the overlay in your activity's own view hierarchy.

如果所讨论的活动不是您自己的活动,那么AFAIK将无法实现您想要的.至少目前,Android中的Windows完全是矩形的.我完全不知道您可以将窗口设置为非矩形,并使活动真正成为那些透明区域中最重要的项目.而且,出于安全原因(窃听攻击),自Android 4.0以来,传递触摸事件的行为已被阻止.

If the activity in question is not your own activity, then AFAIK what you want is not possible. Windows in Android, at the moment at least, are purely rectangular; I know of no way that you can set up your window to be non-rectangular and have the activity truly be the top-most item in those transparent areas. And, passing touch events along has been blocked since Android 4.0, for security reasons (tapjacking attacks).

这篇关于将窗口叠加层上的触摸事件传递到其后面的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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