gpt4 book ai didi

java - WindowManager float 窗口穿过屏幕边框

转载 作者:行者123 更新时间:2023-11-30 00:18:54 25 4
gpt4 key购买 nike

我对由 windowmanager 提供支持的 float 窗口有疑问。它停在屏幕边界处,但我希望它通过。

void startF(int x, int y) {

removePopup();

DisplayMetrics displayMetrics = new DisplayMetrics();
mainActivity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
screenHeight = displayMetrics.heightPixels;
screenWidth = displayMetrics.widthPixels ;

gestureDetector = new GestureDetector(mainActivity, new SingleTap());

windowManager = (WindowManager) mainActivity.getSystemService(Context.WINDOW_SERVICE);

linearLayout = new LinearLayout(mainActivity);
linearLayout.setBackgroundColor(mainActivity.getResources().getColor(R.color.red));

final WindowManager.LayoutParams WMparams = new WindowManager.LayoutParams(100,100,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSPARENT);

//WMparams.gravity = Gravity.CENTER | Gravity.END;

WMparams.x = x;
WMparams.y = y;

windowManager.addView(linearLayout, WMparams);

如图所示

enter image description here

最佳答案

将以下标志添加到窗口:FLAG_LAYOUT_NO_LIMITS

Window flag: allow window to extend outside of the screen.

关于java - WindowManager float 窗口穿过屏幕边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46688484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com