美文网首页
popupWindow 在指定位置上的显示

popupWindow 在指定位置上的显示

作者: 梦沉薇露 | 来源:发表于2016-07-27 12:29 被阅读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]);//右边

相关文章

网友评论

      本文标题:popupWindow 在指定位置上的显示

      本文链接:https://www.haomeiwen.com/subject/etyojttx.html