Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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..

like image 575
Nativ Avatar asked Jun 27 '14 17:06

Nativ


1 Answers

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);
like image 111
Joe3112 Avatar answered Sep 29 '22 05:09

Joe3112