decorView.setSystemUiVisibility()
メソッドにフラグをセットする方法です。※APIレベル14以上
private void hideStatusAndNavigationBar() {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION || View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
isFullScreen = true;
}
private void showStatusAndNavigationBar() {
View decorView = getWindow().getDecorView();
int mask = ~(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION || View.SYSTEM_UI_FLAG_FULLSCREEN);
int uiOptions = decorView.getSystemUiVisibility() && mask;
decorView.setSystemUiVisibility(uiOptions);
isFullScreen = false;
}