如何创建的Andr​​oid系统的覆盖,让与它下面的窗口互动? [英] How to create a system overlay in Android which allows interaction with the windows below it?

查看:148
本文介绍了如何创建的Andr​​oid系统的覆盖,让与它下面的窗口互动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在本应用所看到的,我想创建一个通过创建一个阴影覆盖变暗屏幕的应用程序。

As seen in this app, I want to create an app which dims the screen by creating a shaded overlay.

创建的窗口,它是部分透明的,但是,我不能得到它下面的应用程序启动。我可以点击他们,看到按钮presses,但我正在运行时,其他应用程序无法启动。

The window is created, and it's partially transparent, however, I cannot get the applications below it to launch. I can click them, and see the button presses, but other apps cannot launch while mine is running.

建议?

我附上我的code以下,和一个应用程序,它已经在这样做的一个例子。

I enclosed my code below, and an example of an app which is already doing this.

final WindowManager.LayoutParams params = new WindowManager.LayoutParams( 
    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
    WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | 
    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | 
    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
    WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
    PixelFormat.TRANSLUCENT);   

    WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);    

    LayoutInflater inflater = (LayoutInflater)   getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    ViewGroup mTopView = (ViewGroup) inflater.inflate(R.layout.activity_black, null);
    getWindow().setAttributes(params);
    wm.addView(mTopView, params);

https://play.google.com/store/apps/详细信息?ID = com.haxor

推荐答案

这是简单的方式:

对话对话框=新的对话框(这一点,android.R.style.Theme_DeviceDefault_Dialog_NoActionBar_MinWidth);
          。dialog.getWindow()的setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
          。dialog.getWindow()和setFormat(PixelFormat.TRANSLUCENT);
          dialog.getWindow()setDimAmount(0)。
          dialog.setContentView(新的EditText(本));
          dialog.show();

这篇关于如何创建的Andr​​oid系统的覆盖,让与它下面的窗口互动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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