Showing a view in WindowManager that can come from "out of screen"
Asked Answered
S

2

5

I'm having the following issue - I'm having a view that I'm putting inside the WindowManager and I would like it to come in translate animation from out of the screen and toward the middle of the screen.

Unfortunately, no matter what I do the view sticks to the axis.

This is the code:

    view = (FrameLayout) LayoutInflater.from(this).inflate(
            R.layout.poke, null);

    final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            300, 400, WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);

    params.verticalMargin = -10f;
    params.gravity = Gravity.TOP;

    windowManager.addView(view, params);

As you can see I tried playing with the margin (put there minus to make it go up).

By the way - I know that it's ugly to put numbers and not dp in dimen.xml. Its just a test code..

Socialite answered 27/6, 2014 at 17:52 Comment(0)
A
13

I just faced the same issue and the actual flag is:

WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS

So your code should look like:

final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
        300, 400, WindowManager.LayoutParams.TYPE_PHONE,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
        PixelFormat.TRANSLUCENT);
Atkins answered 8/1, 2015 at 19:28 Comment(0)
J
-1

In the flags that you are specifying, add another flag FLAG_LAYOUT_NO_LIMITS.

That should allow you to place your views even outside the screen.

Your code should look like this:

final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
     300, 400, WindowManager.LayoutParams.TYPE_PHONE,
     WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
     PixelFormat.TRANSLUCENT);
Jamie answered 14/10, 2014 at 6:17 Comment(1)
there is nothing like FLAG_LAYOUT_NO_BOUNDSVisakhapatnam

© 2022 - 2024 — McMap. All rights reserved.