1

I have a problem with floating window powered by windowmanager. It stops at screen border but i want it to go through.

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);

As in the picture

enter image description here

Aldeguer
  • 821
  • 9
  • 32
Kmopsuy
  • 95
  • 1
  • 2
  • 10

1 Answers1

1

Add the following flag to the window: FLAG_LAYOUT_NO_LIMITS

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

RobCo
  • 6,240
  • 2
  • 19
  • 26