Search code examples
androidpopupwindowandroid-popupwindow

Android Popup Window X and Y positioning


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);

Solution

  • 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