java 三星 Galaxy S8 全屏模式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43694526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 07:39:34  来源:igfitidea点击:

Samsung Galaxy S8 full screen mode

javaandroidfullscreendisplaysamsung-galaxy

提问by Barmaley Red Star

Latest Samsung's smartphone has interesting feature called full screen(or in marketing terms infinity display). In this mode app covers also part of display where home/back buttons are. Usual apps don't cover this area, leaving it black. But Samsung's native ones cover this area.

最新的三星智能手机具有有趣的功能,称为全屏(或在营销术语中为无限显示)。在这种模式下,应用程序还覆盖了主页/后退按钮所在的部分显示。通常的应用程序不覆盖此区域,将其保留为黑色。但三星的原生产品涵盖了这一领域。

Question: how to achieve this effect? I mean what kind of manifest declaration or programmatic call (possibly Samsung's legacy API) should I use?

问题:如何实现这个效果?我的意思是我应该使用什么样的清单声明或编程调用(可能是三星的遗留 API)?

回答by Maris B.

To enable new Samsung Galaxy S8 and LG G6 full screen support add to the AndroidManifest.xml under the <application>element:

要启用新的三星 Galaxy S8 和 LG G6 全屏支持,请添加到 AndroidManifest.xml<application>元素下:

<meta-data android:name="android.max_aspect" android:value="2.1" />

Where value of 2.1 is aspect ratio 18.5:9 (By default your App defaults to maximum ratio for 16:9 - 1.86). More info in: Android Blog.

其中 2.1 的值是纵横比 18.5:9(默认情况下,您的应用默认为 16:9 - 1.86 的最大比例)。更多信息请访问:Android 博客

Alternatively, you can set the following attribute for Application or Activity:

或者,您可以为应用程序或活动设置以下属性:

android:resizeableActivity="true"

Because the documentations states (link):

因为文档说明(链接):

You do not need to set a maximum aspect ratio if an activity's android:resizeableActivity attribute is set to true. If your app targets API level 24 or higher, this attribute defaults to true.

如果 Activity 的 android:resizeableActivity 属性设置为 true,则不需要设置最大纵横比。如果您的应用面向 API 级别 24 或更高级别,则此属性默认为 true。

回答by Abubakar

to get full-screen you must overide onWindowFocusChangedmethod and create decorViewobject and add System_UI flags into it..

要获得全屏,您必须覆盖onWindowFocusChanged方法并创建装饰视图对象并将 System_UI 标志添加到其中..

@Override
    public  void onWindowFocusChanged(boolean  hasFocus){
        super.onWindowFocusChanged(hasFocus);
        View decorView = getWindow().getDecorView();
        if(hasFocus){

        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    |View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY  // this flag do=Semi-transparent bars temporarily appear and then hide again
                    |View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN  // Make Content Appear Behind the status  Bar
                    |View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION  // it Make Content Appear Behind the Navigation Bar
                    |View.SYSTEM_UI_FLAG_FULLSCREEN  // hide status bar
                    |View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        }
    }

回答by Zunair Nasir

It can be turned off. I used this tutorial for my S8

它可以关闭。我将本教程用于我的 S8

How To Enable Full Screen Apps on Galaxy S8/S8+

如何在 Galaxy S8/S8+ 上启用全屏应用