參考:http://www.cnblogs.com/sw926/p/3230659.htmlhtml
注意:java
PopupWindow會給PopupView設置Padding,會致使ContentView的左右上下都會存在空隙。htm
解決以下:blog
在顯示PopupWindow(即執行PopupWindow.showAtLocation())後,從新設置PopupView的padding。get
popupWindow.showAtLocation(x,x,x,x,); ViewGroup popupView = (ViewGroup) popupWindow.getContentView().getParent(); if (popupView != null) { popupView.setPadding(0, 0, 0, 0); }