Android 隐藏底部导航栏和状态栏,动态调用导航栏,键盘收回时也收回导航栏


private void hideNavigationBar() {

Window window= getWindow();

    WindowManager.LayoutParams params = window.getAttributes();

    params.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE|View.SYSTEM_UI_FLAG_FULLSCREEN;

    window.setAttributes(params);

    int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE

            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar

            | View.SYSTEM_UI_FLAG_FULLSCREEN; // hide status bar

    if (Build.VERSION.SDK_INT >=19) {

uiFlags |=0x00001000;  //SYSTEM_UI_FLAG_IMMERSIVE_STICKY: hide navigation bars - compatibility: building API level is lower thatn 19, use magic number directly for higher API target level

    }else {

uiFlags |= View.SYSTEM_UI_FLAG_LOW_PROFILE;

    }

getWindow().getDecorView().setSystemUiVisibility(uiFlags);

}

你可能感兴趣的:(Android 隐藏底部导航栏和状态栏,动态调用导航栏,键盘收回时也收回导航栏)