其他分享
首页 > 其他分享> > WindowManager

WindowManager

作者:互联网


WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        WindowManager.LayoutParams layoutParams=new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT
																			   ,0,0,PixelFormat.TRANSPARENT);
		
        layoutParams.flags= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE//表示当前Window不需要获取焦点,也不需要获取输入事件,事件会直接传递给下面的view
			|WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL//表示当前Window区域之外的单击事件向下传递,区域内部的事件由自己处理
			| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;//window显示在锁屏之上
        layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
		
		//透明层
		layoutParams.format=PixelFormat.TRANSPARENT;//不加这句可能会addView不上去
		
		
		LayoutInflater Inflater=(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View mainview=Inflater.inflate(R.layout.desktop_window_pops,null);
        windowManager.addView(mainview,layoutParams);

度之 发布了1 篇原创文章 · 获赞 0 · 访问量 11 私信 关注

标签:SERVICE,LayoutParams,WindowManager,Inflater,layoutParams,FLAG
来源: https://blog.csdn.net/weixin_45338745/article/details/104141462