PopupWindow的show 7.0以後的適配,如下。
PopupWindow是在vTarget下方展示的,PopupWindow的上邊對齊vTarget的上邊,高度是vTarget的上邊到屏幕底邊。showAtLocation()方法第二個參數Gravity.TOP | Gravity.LEFT表示從屏幕上邊show,後面是偏移量。
if (mPopupWindow != null && !mPopupWindow.isShowing()) {
//7.0以下
if (Build.VERSION.SDK_INT < 24) {
mPopupWindow.showAsDropDown(vTarget, 0, -vTarget.getHeight());
} else {
Rect rect = new Rect();
vTabWholeLayout.getGlobalVisibleRect(rect);
int height = DeviceUtils.getScreenHeight() - rect.top + StatusBarUtil.getStatusBarHeight(mCon);
mPopupWindow.setHeight(height);
mPopupWindow.showAtLocation(vTarget, Gravity.TOP | Gravity.LEFT,
0, rect.top);
}
}
如下圖,vTarget就是tab欄,點擊右側箭頭 彈出PopupWindow。