隐藏底部导航栏 - 在底部显示白色条带

时间:2017-02-10 09:33:16

标签: android

我需要隐藏底部导航栏。     我用这些标志作为:

getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_IMMERSIVE
                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN
But blank white strip appears at bottom of device.
How to remove that?

我的流程就像这个MainActivity - > HomeFragment - > InventoryFragment。 在InventoryFragment中,我想删除导航栏。

1 个答案:

答案 0 :(得分:0)

View.SYSTEM_UI_FLAG_IMMERSIVE替换为View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY

AppCompatActivity代码:

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.your_layout);
mDecorView = getWindow().getDecorView();

int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN |
    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
    View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
    View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
mDecorView.setSystemUiVisibility(uiOptions);
}

Xml布局文件:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFE744"
tools:context="....">

APP主题:

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@color/custom_black</item>
</style>

AppCompatActivity主题与应用主题相同