Created
June 6, 2014 07:07
-
-
Save Reacoder/67c009dd9680b7ca3ad9 to your computer and use it in GitHub Desktop.
Show or hide status bar.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void hideStatusBar() { | |
if (Build.VERSION.SDK_INT < 16) { | |
hideStatusBarLowVersion(); | |
} else { | |
hideStatusBarHighVersion(); | |
} | |
} | |
private void showStatusBar() { | |
if (Build.VERSION.SDK_INT < 16) { | |
showStatusBarLowVersion(); | |
} else { | |
showStatusBarHighVersion(); | |
} | |
} | |
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) | |
private void showStatusBarHighVersion() { | |
View decorView = getWindow().getDecorView(); | |
int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; | |
decorView.setSystemUiVisibility(uiOptions); | |
} | |
private void showStatusBarLowVersion() { | |
getWindow().addFlags( | |
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); | |
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); | |
} | |
private void hideStatusBarLowVersion() { | |
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); | |
getWindow().clearFlags( | |
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); | |
} | |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) | |
private void hideStatusBarHighVersion() { | |
View decorView = getWindow().getDecorView(); | |
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; | |
decorView.setSystemUiVisibility(uiOptions); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment