Solve the problem that Android cannot hide the virtual button ultimate version after displaying PopupWindow

After setting the shadow hiding virtual button for the Activity, the virtual button comes out again after the PopupWindow pops up. Baidu has searched all over, but no one can solve it. Just copy the following code to realize the shadow hiding. It works on the Android highland version in my personal test:

 /**
     * 影藏PopupWindow页面弹出时的虚拟按键
     */
    public static void hideBottomUIMenuForPopupWindow(final PopupWindow popupWindow) {
        if (popupWindow != null && popupWindow.getContentView() != null) {
            popupWindow.getContentView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
                @Override
                public void onSystemUiVisibilityChange(int visibility) {
                    //        //保持布局状态
                    int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                            //布局位于状态栏下方
                            View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
                            //全屏
                            View.SYSTEM_UI_FLAG_FULLSCREEN |
                            //隐藏导航栏
                            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
                    if (Build.VERSION.SDK_INT >= 19) {
                        uiOptions |= 0x00001000;
                    } else {
                        uiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
                    }
                    popupWindow.getContentView().setSystemUiVisibility(uiOptions);
                }
            });
        }
    }

 

Guess you like

Origin blog.csdn.net/zhao8856234/article/details/117789795