I was wondering if there is a way to hide an Android device's soft keys (status and navigation bars) right when an app launches? Take, for instance, a game that initially displays a black screen while hiding the soft keys in runtime prior to the brand, title, and main menu screen.
I included the following code snippet in my MainActivity, and when the app launches, I initially see a white screen with the soft keys in runtime for about a second and then the softkeys later disappear when MainActivity's thread finishes running:
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
getWindow().getDecorView().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
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
Thanks a bunch.
* UPDATE AS OF 1/19/2017: * After including:
<item name="android:windowFullscreen">true</item>
... into the app's theme, only the status bar hides on time as opposed to the navigation bar. My second post - Hiding the navigation bar immediately on app launch
have a look into your styles.xml and add the item android:windowFullscreen.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowFullscreen">true</item>
</style>
I hope that helps.
Ben
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With