Android hide soft keys on nexus devices

半腔热情 提交于 2019-12-12 22:15:46

问题


I want to hide the soft key bar (home, back, menu) when a user launches my app. I tried using:

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

But unfortunately as soon as the user interacts with my app, the soft key bar shows again. Is there any way to hide it till the user exits my app?


回答1:


This is called immersive mode.

check out: https://developer.android.com/training/system-ui/immersive.html

The code that you were asking for is:

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

Happy???



来源:https://stackoverflow.com/questions/29181671/android-hide-soft-keys-on-nexus-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!