I'm building an app for Android (6.0, but I can change it if necessary), and having trouble getting the status and navigation bars to hide properly. I've followed every online suggestion I can find, but the two bars both hide properly whenever the app is launched or resumed, but they instantly reappear whenever I tap. I've added the following code to styles.xml
:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name = "android:windowActionBar">false</item>
<item name = "android:windowNoTitle">true</item>
</style>
And in MainActivity.java
:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hideBars();
}
@Override
public void onResume(){
super.onResume();
hideBars();
}
void hideBars(){
setContentView(R.layout.activity_main);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
}
How can I get the two bars to go away permanently without immediately reappearing when I tap?