I am trying to overlay screen using WindowManager and it is working well but the overlay screen doesn't overlay the footer but overlay header.
And here is my code.
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);
Please help me with the overlaying footer. Thank you!
I found the solution by myself.
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);
It is working well.