admin管理员组

文章数量:1794759

Android开发:隐藏和显示底部导航栏

Android开发:隐藏和显示底部导航栏

描述:视频播放器实现全屏和小屏互相切换时,显示和隐藏底部导航栏的方法

该例子设置的Activity是去除状态栏和标题栏,全屏显示布局和电量等信。Manifest文件 theme如下:

<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>

 显示和隐藏底部导航栏的方法:

/** * 控制底部导航栏,显示/隐藏虚拟按键 * * @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); } }

 

本文标签: android