protected void hideBottomUIMenu() {
//隐藏底部导航栏
final View decorView = getWindow().getDecorView();
final int uiOption = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;

decorView.setSystemUiVisibility(uiOption);

// This code will always hide the navigation bar
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
decorView.setSystemUiVisibility(uiOption);
}
}
});
}

建议把方法写在


BaseActivity 中


这样在每个页面中都可以使用

protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hideBottomUIMenu();
。。。
}