0

我想隐藏导航栏。如果用户从外到内给他的手指吸毒,Onyl 会显示它。我测试这段代码:

@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);
    }
}

活动开始良好,导航栏不出现。Buti 有下一个问题: 1)如果在导航栏显示的任何地方触摸屏幕。2)当它显示时,它不显示透明。3) 导航栏从不隐藏。

这三个项目怎么加?我错过了什么。

4

1 回答 1

0

Add the sticky flag View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY to setSystemUiVisibility as described in the documentation https://developer.android.com/training/system-ui/immersive.html#sticky

That way after swiping from the screen edge, navigation bars will show for some seconds and then hide again.

于 2016-10-20T20:45:40.423 回答