0

I have a popup window in android Any body can say me the X and Y positon mean in an android screen.Is it refer to the screen window or refer to the button poping the window. This is My code

       int[] location = new int[2];
            Object position = null;
            Object currentRowId = position;
            View currentRow = v;    

            v.getLocationOnScreen(location);


            Point point = new Point();
            point.x = location[0];
            point.y = location[1];



       PopupWindow changeStatusPopUp = new PopupWindow(context);
       changeStatusPopUp.setContentView(layout);
       changeStatusPopUp.setWidth(165);
       changeStatusPopUp.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
       changeStatusPopUp.setFocusable(true);


       int OFFSET_X = -80;
       int OFFSET_Y = 50;


       changeStatusPopUp.setBackgroundDrawable(new BitmapDrawable());


       changeStatusPopUp.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + 
                   OFFSET_X, p.y + OFFSET_Y);

2 Answers2

0

It would refer where u r popping the window.. For example, if B represents address 100, then the expression, B+5 would signify the address 105. The 5 in the expression is the offset

Akshay Sharma
  • 418
  • 3
  • 12
0

The X,Y offsets are relative to the Window, to which anchor view belongs. Your offsets need to be relative to the anchor's position in its window. You can retrive the anchor's position using getWindowVisibleDisplayFrame

Freddroid
  • 2,449
  • 22
  • 23