使用 WindowManager 覆盖页脚

Overlay footer using WindowManager

我正在尝试使用 WindowManager 覆盖屏幕,它运行良好,但覆盖屏幕不覆盖页脚,而是覆盖页眉。

这是我的代码。

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

        overlayView_bg = new View(getApplicationContext());
        // making service view fullscreen
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
                WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | 
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | 
                WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH ,
                PixelFormat.TRANSLUCENT);
        wm.addView(overlayView_bg, params);

请帮我处理叠加页脚。 谢谢!

我自己找到了解决方案。

        int navigationHeight = 0, statusHeight = 0;
        Resources resources = getApplicationContext().getResources();
        int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
        if (resourceId > 0) {
            navigationHeight= resources.getDimensionPixelSize(resourceId);
        }
        resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            statusHeight = resources.getDimensionPixelSize(resourceId);
        }
        DisplayMetrics displayMetrics = getApplicationContext().getResources().getDisplayMetrics();
        float dpHeight = displayMetrics.heightPixels ;

        // making service view fullscreen
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                -1,(int)(dpHeight + navigationHeight + statusHeight),0,-navigationHeight,
                LAYOUT_FLAG,
                WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | 
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | 
                WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | 
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | 
                WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR| 
                WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.BOTTOM | Gravity.LEFT;
        wm.addView(overlayView_bg, params);

运行良好。