As we all saw, the Android API is constantly changing. Here is a more relevant answer to the question.
According to this document: https://developer.android.com/tutorial/system-ash/status.html
Hide status bar on Android 4.1 and higher
You can hide the status bar on Android 4.1 (API level 16) and higher using setSystemUiVisibility (). setSystemUiVisibility () sets the UI flags to an individual viewing level; these parameters are aggregated in the level window. Using setSystemUiVisibility () to set UI flags gives you more granular control over system strings than using WindowManager flags. This snippet hides the status bar:
decorView = getWindow(). getDecorView(); // . int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); // , , // , . ActionBar actionBar = getActionBar(); actionBar.hide(); >
Borrowing groovy XOR from other answers:
public void toggleFullscreen() { decorView = getWindow(). GetDecorView(); int uiOptions = decorView.getSystemUiVisibility(); uiOptions ^ = View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); } >
This works (I use it) and seems to work the same as getWindow(). setAttributes() solution getWindow(). setAttributes() getWindow(). setAttributes() , but this is recommended in the developer docs.
ByteSlinger
source share