Android development: hide and show bottom navigation bar

Description: The method of displaying and hiding the bottom navigation bar when the video player switches between full screen and small screen

The Activity set in this example is to remove the status bar and title bar, and display information such as layout and power in full screen. The Manifest file theme is as follows:

<activity
            android:name=".ui.activity.UnReadListActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme_Translucent"
            android:windowSoftInputMode="adjustResize" />

 <style name="AppTheme_Translucent" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowTranslucentStatus">true</item>
    </style>

 How to show and hide the bottom navigation bar:

 /**
     * 控制底部导航栏,显示/隐藏虚拟按键
     *
     * @param isShow true:显示;false:隐藏
     */
    private void controlBottomNavigation(boolean isShow) {
        //隐藏虚拟按键
        if (isShow) {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        } else {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_IMMERSIVE);
        }
    }

 

Guess you like

Origin blog.csdn.net/android157/article/details/124735782