LayoutInflater li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);

    params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.RIGHT | Gravity.TOP;
    myview = li.inflate(R.layout.locked_layout, null);
    wm.addView(myview);

这是我用于在屏幕上覆盖布局的代码。只有 HOME 按钮有效。但是后退按钮不起作用。我想要两个都工作。我错过了什么吗?请帮我!!提前致谢

最佳答案

我的 friend 也添加这个标志:

WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE

关于android - 使用 WindowManager 覆盖布局时,后退按钮不起作用。如何使它工作?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24595849/

10-14 05:09