android overlay picture not reaching top of screen

162 Views Asked by At

I am trying to fit this overlay image to the very top of the screen:

enter image description here

This is my code for the overlay:

WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.LEFT | Gravity.TOP;
    params.x = 0;
    params.y = 0;
    wm.addView(overlayedButton, params);

Why is the picture not meeting the top of the screen? Thanks for any pointers!

Here is the image of the sun:

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

My problem was that I was using an ImageButton rather than an ImageView.