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。