-
-
Save mdakram/9501455 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Sets full screen mode on the device, by setting parameters in the current | |
* window and View | |
* @param fullscreen | |
*/ | |
public void setFullScreen(boolean fullscreen) { | |
// If full screen is set, sets the fullscreen flag in the Window manager | |
getWindow().setFlags( | |
fullscreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0, | |
WindowManager.LayoutParams.FLAG_FULLSCREEN); | |
// Sets the global fullscreen flag to the current setting | |
mFullScreen = fullscreen; | |
// If the platform version is Android 3.0 (Honeycomb) or above | |
if (Build.VERSION.SDK_INT >= 11) { | |
// Sets the View to be "low profile". Status and navigation bar icons will be dimmed | |
int flag = fullscreen ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0; | |
// If the platform version is Android 4.0 (ICS) or above | |
if (Build.VERSION.SDK_INT >= 14 && fullscreen) { | |
// Hides all of the navigation icons | |
flag |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; | |
} | |
// Applies the settings to the screen View | |
mMainView.setSystemUiVisibility(flag); | |
// If the user requests a full-screen view, hides the Action Bar. | |
if ( fullscreen ) { | |
this.getActionBar().hide(); | |
} else { | |
this.getActionBar().show(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment