Android 7.0 and above PopupWindow adaptation issues

Android 7.0 and above PopupWindow location will appear abnormal, background shading may also be abnormal, need to dynamically calculate the height.

        //popupWindow 适配7.0及以上系统显示问题
        if (Build.VERSION.SDK_INT >= 24) {
            Rect rect = new Rect();
            mTabLayout.getGlobalVisibleRect(rect);
            int height = mTabLayout.getResources().getDisplayMetrics().heightPixels - rect.bottom;
            popupWindow.setHeight(height);
        }
        popupWindow.showAsDropDown(mTabLayout, 0, 0);

Published 246 original articles · won praise 441 · views 680 000 +

Guess you like

Origin blog.csdn.net/yechaoa/article/details/102523474