Galaxy S10、S10+ 全屏模式

Galaxy S10, S10+ Full Screen Mode

三星Galaxy S10和S10+如何实现全屏模式,以下代码对我不起作用:

getWindow().getDecorView().setSystemUiVisibility(
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);

它隐藏了状态栏的内容,但它本身并没有隐藏状态栏:(

请帮忙

尝试创建样式:

<style 
    name="Theme.AppCompat.Light.NoActionBar.FullScreen" 
    parent="@style/Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

然后将主题应用到您的 activity:

<activity
   android:name=".MyActivity"
   android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" 
/>

更新:

据我所知,三星 S10 的纵横比为 19:9(相当于 2.1) 因此,在您的清单中,将此标签添加到您的 <application>

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

您也可以尝试为 Activity 或 Application:

设置 resizeableActivity
android:resizeableActivity="true"

在您的应用样式中加入以下内容为我解决了这个问题:

<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>

有关支持剪切的更多详细信息,请查看:

https://developer.android.com/guide/topics/display-cutout

来自 Mohamad Bdour 链接的文档:

Note that Android might not allow the content view to overlap the system bars. To override this behavior and force content to extend into the cutout area, apply any of the following flags to the view visibility via the View.setSystemUiVisibility(int) method:

SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION SYSTEM_UI_FLAG_LAYOUT_STABLE