Reputation: 3275
I'm having some trouble hiding the status bar.
If I use this code to enter full immersive mode (hide statusbar and navigation) it DOES hide the navigation but the statusbar just keeps sitting there:
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
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_STICKY
);
}
}
I've also tried using the manifest:
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
Neither works. Also tried the manifest approach without the setSystemUiVis() function (just to test if it would work - which it should because I've used this before) but it doesn't.
Testing on Android 4.4.2 (Sony z2 tablet) and Android L Dev preview (second release, Nexus7)
Help?
Upvotes: 0
Views: 1001
Reputation: 3275
Ok I figured it out. Somehow Cordova (2.7.0) was interfering with the fullscreen stuff.
To get it to work, first edit config.xml in (res/xml/config.xml) and add the following preference:
<preference name="fullscreen" value="true" />
Then, in the onWindowFocusChanged method, comment this line:
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
So it should look like this:
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
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_STICKY
);
}
}
Last but not least: DO NOT use a .Fullscreen theme in your manifest.
Whoop.
Upvotes: 1