悬浮view覆盖状态栏

来源:互联网 发布:电信网络测速112 编辑:程序博客网 时间:2024/05/16 15:20

int titleBarHeight = ScreenUtil.getStatusBarHeight(mContext);
int titleHeight = ScreenUtil.dp2Px(mContext,44);
WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
titleBarHeight+titleHeight,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_FULLSCREEN,
PixelFormat.TRANSLUCENT);

wmParams.gravity = Gravity.TOP | Gravity.LEFT;
wmParams.y = -titleBarHeight;
wmParams.x = 0;

我想要的效果是覆盖状态栏,点击屏幕可以跳转其他界面修改为以下:
int titleBarHeight = ScreenUtil.getStatusBarHeight(mContext);
int titleHeight = ScreenUtil.dp2Px(mContext,44);
int pushHeight = titleHeight+titleBarHeight;
WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
pushHeight,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);

    wmParams.gravity = Gravity.TOP | Gravity.LEFT;    wmParams.y = -titleBarHeight;    wmParams.x = 0;
0 0
原创粉丝点击