popupWindow 在指定位置上的显示

2016-07-27  本文已影响0人  梦沉薇露
    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]);//右边

上一篇 下一篇

猜你喜欢

热点阅读