0
我有一個由windowmanager提供動力的浮動窗口有問題。它停在屏幕邊框,但我希望它通過。WindowManager浮動窗口通過屏幕邊框
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);
如在圖像
噢,非常感謝! – Kmopsuy
+它不適用於TYPE_SYSTEM_ERROR,但我將其更改爲TYPE_PHONE – Kmopsuy