I call this function in onCreate of every activity of my app project:

public void hideDeviceBottomNav ()
{
    View decorView = getWindow().getDecorView();

    final int flags = 
      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;

    decorView.setSystemUiVisibility(flags);

    decorView.setOnSystemUiVisibilityChangeListener
            (new View.OnSystemUiVisibilityChangeListener() {
                @Override
                public void onSystemUiVisibilityChange(int visibility) {
                    // Note that system bars will only be "visible" if none of the
                    // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
                    if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                        // TODO: The system bars are visible. Make any desired
                        // adjustments to your UI, such as showing the action bar or
                        // other navigational controls.
                        decorView.setSystemUiVisibility(flags);
                    } else {
                        // TODO: The system bars are NOT visible. Make any desired
                        // adjustments to your UI, such as hiding the action bar or
                        // other navigational controls.

                    }
                }
            });
}

and still every time I touch the search icon in my SearchView to search in my ListView or create and show new custom Dialog, the bottom navigation bar appears... .

In addition, how can I hide the bottom navigation only without hiding the upper bar ?

1

There are 1 answers

0
Intergalactic On

The questioned is answered here. Easiest way is to put in Manifest: <activity android:name=".MainActivity" android:windowSoftInputMode="adjustPan">