小编Fra*_*lez的帖子

Android 中带有缺口的黑条在沉浸式模式下使用 cordova

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

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

setTimeout(function(){
    if (window.AndroidFullScreen) { 
        window.AndroidFullScreen.immersiveMode(); 
        AndroidFullScreen.showUnderStatusBar();
        AndroidFullScreen.showUnderSystemUI();
}, 2000);
Run Code Online (Sandbox Code Playgroud)

(我还需要使用超时来应用更改,我不知道为什么,无论如何要在应用程序启动时应用代码,我正在使用 deviceready。

  • 这使得它使用凹口全屏。我使用插件将其放入 javascript 文件中。
AndroidFullScreen.setSystemUiVisibility(
        AndroidFullScreen.SYSTEM_UI_FLAG_LAYOUT_STABLE
        | AndroidFullScreen.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
        | AndroidFullScreen.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
        | AndroidFullScreen.SYSTEM_UI_FLAG_HIDE_NAVIGATION
        | AndroidFullScreen.SYSTEM_UI_FLAG_FULLSCREEN
        | AndroidFullScreen.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
    , successFunction, errorFunction
);
Run Code Online (Sandbox Code Playgroud)

但问题是系统UI没有隐藏,当我从顶部拖动打开通知菜单并将其隐藏时,UI最终消失但屏幕又回到有黑条,所以它就像旧的沉浸模式()(同样这段代码又在setTimeOut中)。

我的配置.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" …
Run Code Online (Sandbox Code Playgroud)

javascript android cordova

3
推荐指数
1
解决办法
3302
查看次数

标签 统计

android ×1

cordova ×1

javascript ×1