2

我的应用可以选择进入全屏模式。设备三星 Galaxy S7 Edge 的用户向我报告说,在这种情况下会显示导航软按钮,并且在应用全屏时不会消失。

这是我正在使用的代码:

getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                    | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                            | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            );
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

mainFrame.setSystemUiVisibility(
                        View.SYSTEM_UI_FLAG_LOW_PROFILE |
                        View.SYSTEM_UI_FLAG_FULLSCREEN |
                        View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                        View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
                        View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
                        View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
        );

我已经尝试了一些选项,但这很难,因为我没有三星设备。有这个设备的人可以告诉我正确的设置,这样导航软键就不会在全屏模式下显示吗?

4

1 回答 1

1

i found something that might be helpfull. It's from Google's Developers site and I think it does exactly what you are looking for. I hope it will be some kind of help.

I think this part in the beginning is what you need but I also provide you a link below for more information:

Android 4.4 (API Level 19) introduces a new SYSTEM_UI_FLAG_IMMERSIVE flag for setSystemUiVisibility() that lets your app go truly "full screen." This flag, when combined with the SYSTEM_UI_FLAG_HIDE_NAVIGATION and SYSTEM_UI_FLAG_FULLSCREEN flags, hides the navigation and status bars and lets your app capture all touch events on the screen.

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

EDIT

i found an answer to a similar question with yours and the suggested approach is the following. try adding this to your code. it will do the trick.

int UI_OPTIONS = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | 
   View.SYSTEM_UI_FLAG_FULLSCREEN | 
   View.SYSTEM_UI_FLAG_LAYOUT_STABLE | 
   View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | 
   View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;

getWindow().getDecorView().setSystemUiVisibility(UI_OPTIONS);

Here is the link to the original: https://stackoverflow.com/a/31483291/8434076

于 2017-08-08T14:36:57.283 回答