Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the soft-key bar on Android phone?

 enter image description here

When my app starts, I'd like to hide the soft keys bar (in red rectangle) to have a larger screen.

  1. How can I hide it?

  2. Do I need to show the bar purposely when the app quits? Or it will restore itself automatically after the app quits?

Android 4.1, with no hardware keys on phone front.

like image 664
ohho Avatar asked Apr 30 '13 03:04

ohho


People also ask

How do I remove the bar from the home screen Android?

In the SureLock Settings screen, navigate to Miscellaneous Settings. Check Use Advance Hide Bottom Bar option to enable it. Once done, the bottom bar on the device will be hidden.

What are soft keys on Android?

(1) A simulated button or keyboard key that is displayed on a touchscreen. Also called a "soft button," "virtual button" or "virtual key," touchscreen soft keys enable smartphones, tablets and remote controls to display any style of user interface.


2 Answers

I know its late but it is the right answer so what you are trying to do is what called immersive mode. for (API 19)

check out: https://developer.android.com/training/system-ui/immersive.html

The code that you were asking for is:

@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);
    }
}
like image 160
mhdjazmati Avatar answered Sep 23 '22 13:09

mhdjazmati


Try

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

From official doc

The SYSTEM_UI_FLAG_LOW_PROFILE flag replaces the STATUS_BAR_HIDDEN flag. When set, this flag enables “low profile" mode for the system bar or navigation bar. Navigation buttons dim and other elements in the system bar also hide. Enabling this is useful for creating more immersive games without distraction for the system navigation buttons.

The SYSTEM_UI_FLAG_VISIBLE flag replaces the STATUS_BAR_VISIBLE flag to request the system bar or navigation bar be visible.

The SYSTEM_UI_FLAG_HIDE_NAVIGATION is a new flag that requests the navigation bar hide completely. Be aware that this works only for the navigation bar used by some handsets (it does not hide the system bar on tablets). The navigation bar returns to view as soon as the system receives user input. As such, this mode is useful primarily for video playback or other cases in which the whole screen is needed but user input is not required.

The behavior of the nav bar is app dependent IIRC, so it should show again after the user leaves your app.

like image 24
MarsAtomic Avatar answered Sep 26 '22 13:09

MarsAtomic