Search code examples
androidcordovaionic2cordova-pluginsionic3

Change the color of Status bar items (symbols) to black


Can I give black color for the status bar items? Because I need to change the background color to white as shown below.Then I can't see the status bar items hence those are also white color.Any help?

Note: I'm testing this on Android device (6.0).

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

Now (i.e. White items):

enter image description here

I need like this(i.e. Black items):

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": {}
    }
  }
}

Solution

  • I'm sorry, but styleDefault is only available on ios and 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
    

    That being said, I think you can only change the background color, but I guess the font color will be set based on that... I've changed the status bar background color several times, using a dark color, and the font color was set to white automatically.