PopupWindow的show 7.0以后的适配

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。
在这里插入图片描述在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章