我一直遇到用户按下并按住电源按钮并显示电源选项窗口的问题,但部分内容隐藏在RelativeLayout
后面。目前我正在设置RelativeLayout
使用:
WindowManager windowManager = (WindowManager) getBaseContext().getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(overlay_width, overlay_height, overlay_left, overlay_top,
WindowManager.LayoutParams.TYPE_TOAST,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,PixelFormat.RGBA_8888 );
params.gravity = Gravity.TOP | Gravity.CENTER;
我需要这个view
在所有内容之前,但我不希望它出现在系统窗口的前面,例如通知下拉栏和断电选项窗口。
建议?
答案 0 :(得分:0)
不使用类型toast WindowManager.LayoutParams.TYPE_TOAST,
而是使用TYPE_PHONE或TYPE_SYSTEM_OVERLAY
我使用此代码及其工作: -
wm = (WindowManager)
final WindowManager.LayoutParams parameters = new WindowManager.LayoutParams(
(int)desired_width, (int)desired_height, LayoutParams.TYPE_PHONE, // First one is width then is height
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT);
检查您是否再次在某处更改类型