Change Android Statusbar color In Cordova

Voakie picture Voakie · Jul 3, 2016 · Viewed 10.8k times · Source

I want to change the Status bar color in Android (I'm using 6.0 for testing). I tried the statusbar plugin and all the solutions I found for it but nothing worked.

This is included in my config.xml <widget>:

<preference name="StatusBarOverlaysWebView" value="true" />
<preference name="StatusBarBackgroundColor" value="#BE1912" />

My index.js uncludes:

if (window.cordova && StatusBar)
{
    StatusBar.backgroundColorByHexString('#3399FF');
}

Added the plugin per package name and github repo.

Nothing worked so far...

Thanks in advance! :)

Answer

Homen picture Homen · Jul 3, 2016

Statusbar plugin will work.Remove these lines from config.xml

<preference name="StatusBarOverlaysWebView" value="true" />
<preference name="StatusBarBackgroundColor" value="#BE1912" />

And write StatusBar.backgroundColorByHexString('#3399FF'); inside deviceready like following

document.addEventListener('deviceready', function(){
StatusBar.backgroundColorByHexString('#3399FF');});