Natsu Natsu - 3 months ago 21
Android Question

Move popup window out of screen

Hello i have this code to show popup window...

final WindowManager.LayoutParams parameters = new WindowManager.LayoutParams(
(width/100)*50, height, WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
parameters.gravity = Gravity.CENTER | Gravity.CENTER;
parameters.x = (width/100)*50;
parameters.y = 0;


But i need to show it out of screen...
When i set x position to more then windows size it's stuck at corner and not go over screen...

Thanks.

Edit: Because some people don't know what i mean.. i mean half outside screen not full..

Answer

You need to add one more flag which is flag_layout_no_limits

final WindowManager.LayoutParams parameters = new WindowManager.LayoutParams(
            (width/100)*50, height, 
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);  

parameters.gravity = Gravity.CENTER | Gravity.CENTER;
parameters.x = (width/2);
parameters.y = 0;