popupWindow 在指定位置上的显示

    popupWindow = new PopupWindow(layout,120,120);  
        
        popupWindow.setFocusable(true);  
        popupWindow.setOutsideTouchable(true);  
        popupWindow.setBackgroundDrawable(new BitmapDrawable());  
          
        int[] location = new int[2];  
        v.getLocationOnScreen(location);  
         
        popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0], location[1]-popupWindow.getHeight());  //上方
        popupWindow.showAsDropDown(v);//下方
        popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0]-popupWindow.getWidth(), location[1]);//左边

        popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0]+v.getWidth(), location[1]);//右边

推荐阅读更多精彩内容