Search code examples
androidnativescript

Set Color of Android StatusBar in NativeScript


I am working with Nativescript 8.5 and want to change the color of the StatusBar. I found already a 4 year old Stackoverflow entry which describes 3 solutions:

  • add androidStatusBarBackground style to Page element
  • add elements to styles.xml (android:statusBarColor, android:windowLightStatusBar, android:windowActionBarOverlay, android:windowTranslucentStatus)
  • set it programmaticially via window.setStatusBarColor (Application.android.startActivity.getWindow().setStatusBarColor(0);)

But non of them changed anything. Any tips?


Solution

  • The Problem was, that there two styles.xml in nativescript projects:

    • app/main/res/values/styles.xml
    • app/main/res/values-v21/styles.xml

    I looked only in the first one, while the seconds one overwrote my android:windowTranslucentStatus. After removing android:windowTranslucentStatus form the second one all methods for settings the color of the statusBar worked.