Javascript Android中的黑色条带凹口,在沉浸模式下使用cordova

Javascript Android中的黑色条带凹口,在沉浸模式下使用cordova,javascript,android,cordova,Javascript,Android,Cordova,我正在制作一个android应用程序,我希望它处于沉浸式模式,我是用插件制作的,但我无法在带有凹口(顶部和底部的黑色条)的android设备上进行沉浸式工作。如何使用整个屏幕 所以我读了很多解决方案: 我正在使用这个插件,这是我在android设备中想要的,没有缺口: (另外,我需要使用超时来应用更改,我不知道为什么,无论如何,要在应用程序启动时应用代码,我使用的是deviceready 这使得它在notch中使用全屏。我使用插件将其放入javascript文件中 但问题是系统UI没有隐

我正在制作一个android应用程序,我希望它处于沉浸式模式,我是用插件制作的,但我无法在带有凹口(顶部和底部的黑色条)的android设备上进行沉浸式工作。如何使用整个屏幕

所以我读了很多解决方案:

  • 我正在使用这个插件,这是我在android设备中想要的,没有缺口:
(另外,我需要使用超时来应用更改,我不知道为什么,无论如何,要在应用程序启动时应用代码,我使用的是deviceready

  • 这使得它在notch中使用全屏。我使用插件将其放入javascript文件中
但问题是系统UI没有隐藏,当我从顶部拖动以打开通知菜单并隐藏它时,UI最终消失,但屏幕返回到黑色条,因此它类似于旧的浸入模式()(此代码也再次出现在setTimeOut中)

my config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.adia.security" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <platform name="android">
        <allow-intent href="market:*" />
        <preference name="AndroidLaunchMode" value="singleInstance" />
        <preference name="DisallowOverscroll" value="true" />
        <preference name="KeepRunning" value="true" />
    </platform>
    <edit-file parent="/manifest/application" target="AndroidManifest.xml">
        <meta-data android:name="android.max_aspect" android:value="2.1" />
        <activity android:resizeableActivity="false" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
    </edit-file>
    <preference name="Fullscreen" value="true" />
    <preference name="StatusBarOverlaysWebView" value="true" />
    <plugin name="cordova-plugin-fullscreen" spec="1.2.0" />
    <plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
    <engine name="android" spec="^7.1.4" />
</widget>

因此,当我将immersiveMode()应用于插件时,我有这样一个问题:

对于其他代码,UI不会消失,当我打开通知菜单并隐藏它时,它会再次返回到第一个图像

我想要的是这样,但不显示UI


谢谢。

我让它工作了。所以我只需要添加styles.xml和以下内容:

<resources>
    <style name="Full">
        <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
    </style>
</resources>

短边
因此,我创建了styles.xml并将其添加到我的www文件夹中,然后将其添加到我的平台android部分的config.xml中:

<platform name="android">
    <resource-file src="www/styles.xml" target="app/src/main/res/values-v28/styles.xml" />
    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:resizeableActivity="false"/>
    </edit-config>
    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
        <activity android:theme="@style/Full"/>
    </edit-config>
    <config-file parent="./application" target="AndroidManifest.xml">
        <meta-data android:name="android.max_aspect" android:value="5.0" />
    </config-file>
</platform>

我在这里找到了解决方案:

谢谢@Fradniev它工作得很好!但是,使用这种方法在应用程序启动时会在屏幕顶部显示几秒钟的黑色状态栏。关于如何隐藏/删除它有什么想法吗?我尝试了cordova插件状态栏,并通过JS使用了StatusBar.hide(),但似乎没有任何效果。因为android主题设置为“@style/Full”在AndroidManifest.xml和您的技术中,它删除了一行旧主题“@android:style/theme.NoTitleBar.Fullscreen”(这一行很好地隐藏了状态栏)。经过2天的搜索,关于如何在android上启动Splashscreen时隐藏状态栏,对于那些获得“未绑定前缀”的用户Cordova出错:您需要将Android命名空间(xmlns:Android=“)添加到config.xml文件中的根小部件元素
<resources>
    <style name="Full">
        <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
    </style>
</resources>
<platform name="android">
    <resource-file src="www/styles.xml" target="app/src/main/res/values-v28/styles.xml" />
    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:resizeableActivity="false"/>
    </edit-config>
    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
        <activity android:theme="@style/Full"/>
    </edit-config>
    <config-file parent="./application" target="AndroidManifest.xml">
        <meta-data android:name="android.max_aspect" android:value="5.0" />
    </config-file>
</platform>