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。
在這裏插入圖片描述在這裏插入圖片描述

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