//--------------- start style.xml --------------
<style name="Fullscreen" parent="AppTheme"> <item name="android:windowNoTitle">true</item> <item name="android:windowActionBar">false</item> <item name="android:windowFullscreen">true</item> <item name="android:windowContentOverlay">@null</item> </style>
//--------------- end style.xml --------------
//--------------- AndroidManisfest.xml ---------------
minSdkVersion 21targetSdkVersion 27
<uses-sdk
android:maxSdkVersion="27"
android:minSdkVersion="21"
android:targetSdkVersion="26" />
<application android:theme="@style/Fullscreen">
</application>
//--------------- end AndroidManisfest.xml ---------------
//------------------ -------- MainActivity.java . --------------------
extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); // getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
hideSystemUI();
super.onCreate(savedInstanceState);
showSystemUI();
}
}
// This snippet hides the system bars. private void hideSystemUI() { // Set the IMMERSIVE flag. // Set the content to appear under the system bars so that the content // doesn't resize when the system bars hide and show. View decorView = getWindow().getDecorView(); decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar | View.SYSTEM_UI_FLAG_IMMERSIVE); } // This snippet shows the system bars. It does this by removing all the flags// except for the ones that make the content appear under the system bars. private void showSystemUI() { View decorView = getWindow().getDecorView(); decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } }//------------------ -------- End MainActivity.java . --------------------
Comments
Post a Comment