View floatingView = LayoutInflater.from(this).inflate(R.layout.floating_window_layout, null);
// Set the alpha value of the floating view to 0 to make it transparent
floatingView.setAlpha(0);
// Set up the layout parameters for the floating window
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSPARENT);
// Add the floating window to the window manager
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
windowManager.addView(floatingView, layoutParams);
1条答案
按热度按时间sqyvllje1#
要捕获没有覆盖的屏幕,您需要确保浮动窗口是透明的。您可以通过将浮动窗口的alpha值设置为0来实现这一点,这将使其完全透明。
下面是如何创建透明浮动窗口的示例:
//创建浮动窗口的布局