窗口管理器视图不允许返回

时间:2015-07-13 06:22:47

标签: android android-windowmanager

我正在从XML添加一个视图到Window Manager视图,一切正常,但是当我想回到之前的活动时,返回按钮不起作用,即使我已经从onBackPressed中的窗口管理器中删除了添加的视图。

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

    localLayoutParams = getWindow().getAttributes();
    localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    localLayoutParams.gravity = Gravity.TOP;
    localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    localLayoutParams.flags = 0x80000000 | localLayoutParams.flags;
    localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    localLayoutParams.height =    WindowManager.LayoutParams.WRAP_CONTENT;
    localLayoutParams.format = PixelFormat.TRANSPARENT;

    localLayoutParams.screenBrightness = brightness / (float) 255;

    LayoutInflater inflater = getLayoutInflater();
    overlay = inflater.inflate(R.layout.activity_main, null);

    manager.addView(overlay, localLayoutParams);

当我按下后退按钮时,这里是删除视图的代码

if(overlay!=null)
 manager.removeView(overlay);

请帮我解决这个问题。

0 个答案:

没有答案