将状态栏项目(符号)的颜色更改为黑色

时间:2017-06-24 14:56:39

标签: android cordova ionic2 cordova-plugins ionic3

我可以为状态栏项目指定黑色吗?因为我需要将背景颜色更改为白色,如下所示。然后我看不到状态栏项目,因此那些也是白色。有什么帮助?

注意:我正在Android设备(6.0)上对此进行测试。

this.statusBar.styleDefault();
this.statusBar.backgroundColorByHexString("#fff");//white

现在(即白色项目):

enter image description here

我需要这样(即黑色物品):

enter image description here

的package.json

{
  "name": "ionic-hello-world",
  "version": "0.0.0",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build --prod",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/brightness": "^3.10.3",
    "@ionic-native/core": "3.12.1",
    "@ionic-native/facebook": "^3.5.0",
    "@ionic-native/network": "^3.11.0",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "2.0.1",
    "cordova-android": "^6.2.3",
    "cordova-plugin-brightness": "^0.1.5",
    "cordova-plugin-facebook4": "^1.9.0",
    "cordova-plugin-statusbar": "~2.2.1",
    "cordova-plugin-whitelist": "^1.3.1",
    "ionic-angular": "3.4.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "lodash": "^4.17.4",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12",
    "cordova-plugin-network-information": "~1.3.3"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.8",
    "@ionic/cli-plugin-cordova": "1.4.0",
    "@ionic/cli-plugin-ionic-angular": "1.3.1",
    "@types/nprogress": "0.0.29",
    "nprogress": "^0.2.0",
    "typescript": "2.3.3"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "An Ionic project",
  "cordova": {
    "platforms": [
      "android"
    ],
    "plugins": {
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-brightness": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-facebook4": {
        "APP_ID": "60",
        "APP_NAME": "app"
      },
      "cordova-plugin-network-information": {}
    }
  }
}

2 个答案:

答案 0 :(得分:3)

对不起,styleDefault仅适用于ios和windows phone(docs

StatusBar.styleDefault
Use the default statusbar (dark text, for light backgrounds).

Supported Platforms
_ iOS
_ Windows Phone 7
_ Windows Phone 8
_ Windows Phone 8.1

话虽这么说,我认为你只能改变背景颜色,但我想基于那样设置字体颜色......我已经改变了状态栏背景颜色多次,使用深色,字体颜色自动设置为白色。

答案 1 :(得分:1)

在xml(主题属性)中:

app.get('x-foo', (req, res) => {
  const foo = '1234';

  res.redirect(url.format({
     pathname: 'x-bar',
     query: {
       foo: foo
     }
   }));
})

app.get('x-bar', (req, res) => {
  console.log(req.query.foo); // logs '1234'
  res.render(...some page)
});

或以编程方式:

<item name="android:windowLightStatusBar">

someView.setSystemUiVisibility(someView.getSystemUiVisibility()| View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); }

抱歉在移动设备上写它很难将代码放到这些代码字段中......