Popupwindow如果需要點擊空白處自動消失,需要設置兩個函數
1、customPopWindow.setFocusable(true);該函數也可以在構造函數中設置,如:mPopupWindow = new PopupWindow(popunwindwow,LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT,true);最后一個參數true即為設定Focusable屬性。
2、customPopWindow.setBackgroundDrawable(new BitmapDrawable());
此處需要注意:上述兩個方法必須放在showAtLocation()方法之前,才能起作用。