简体   繁体   English

Cordova:StatusBar插件适用于模拟器,但不适用于设备

[英]Cordova: StatusBar plugin works on emulator but not on device

I have a cordova project and I installed the StatusBar plugin to color the status bar of the device in the Android platform. 我有一个cordova项目,我安装了StatusBar插件,为Android平台中设备的状态栏着色。 The plugin displays the correct status bar color if I run the project on an AVD (pic1), but when I run it on the device it does not appear to work. 如果我在AVD(pic1)上运行项目,插件会显示正确的状态栏颜色,但是当我在设备上运行它时,它似乎不起作用。

I also noticed that when I run the project on device with the plug in uninstalled the view takes up the entire screen, but if I run it with the plugin installed there is black space between the app view and the top and bottom of the phone's nav bar and status bar (pic2). 我还注意到,当我在设备上运行项目并卸载了插件时,视图会占用整个屏幕,但是如果我在安装了插件的情况下运行它,应用程序视图与手机导航的顶部和底部之间会出现黑色空间酒吧和状态栏(图2)。

Device: Samsung S9 running Android 8.0.0 (Oreo) 设备:三星S9运行Android 8.0.0(奥利奥)
Cordova version: 8.0.0 Cordova版本:8.0.0
StatusBar plugin version: 2.4.2 StatusBar插件版本:2.4.2
Cordova whitelist plugin: 1.3.3 Cordova白名单插件:1.3.3

index.js: index.js:

var app = {
    // Application Constructor
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    },

    // deviceready Event Handler
    //
    // Bind any cordova events here. Common events are:
    // 'pause', 'resume', etc.
    onDeviceReady: function() {
        this.receivedEvent('deviceready');
        StatusBar.backgroundColorByHexString("#CF4D4D");
    },

    // Update DOM on a Received Event
    receivedEvent: function(id) {
    }
};

app.initialize();

PIC1 PIC2

I've tested your code and it works fine on 4 different devices with Android 5, 6, 7 and 8.1, so it's clearly a bug in the plugin. 我已经测试了你的代码,它可以在Android 5,6,7和8.1的4个不同设备上正常工作,所以它显然是插件中的一个错误。 (probably device specific or vendor specific) (可能是设备特定或供应商特定)

So report it on https://issues.apache.org/jira/browse/CB providing all the possible information. 因此,请在https://issues.apache.org/jira/browse/CB上报告,提供所有可能的信息。 (The information on this "question" should be enough) (关于这个“问题”的信息应该足够了)

You can set them in your config.xml too: 您也可以在config.xml设置它们:

<preference name="StatusBarOverlaysWebView" value="true" />
<preference name="StatusBarBackgroundColor" value="#CF4D4D" />
<preference name="StatusBarDefaultScrollToTop" value="false" />

If that helps you in any way. 如果这对你有任何帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM