0

I am trying to follow this code example here: https://www.youtube.com/watch?v=NroxMDGOJ_E but it does not work anymore, at least the change status bar color part. The page.androidStatusBarBackground property does not work anymore. Is there a reliable way to change the background color of the statusbar in android using nativescript core?

jessiPP
  • 436
  • 1
  • 6
  • 21

1 Answers1

1

very simple

  • go to App_Resources\Android\src\main\res\values\styles.xml
  • check with this code and compare yours
<style name="LaunchScreenThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>

        <item name="colorPrimary">@color/ns_primary</item>
        <item name="colorPrimaryDark">@color/ns_primaryDark</item>
        <item name="colorAccent">@color/ns_accent</item>
        <item name="android:windowBackground">@drawable/splash_screen</item>

        <item name="android:statusBarColor">@color/ns_primaryDark</item>
        <item name="android:windowLightStatusBar">true</item>

        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:windowTranslucentStatus">true</item>

    </style>

the important thing is android:statusBarColor & android:windowLightStatusBar

note : it should work fine, you better delete platforms and node_modules folder and run tns run android fresh. It will perfectly work

Vikas Acharya
  • 3,550
  • 4
  • 19
  • 52
  • Thanks for your response but this will only set a global color once. What if I want each page the have their own color? Or maybe I could set the color to translucent or no color. How would I do that? – jessiPP Jun 26 '20 at 10:50
  • 1
    @jessiPP i don't know about for each page. but i already answered about transparency. u must go through each properties in android Docs. refer this for direct answer https://stackoverflow.com/a/29311321/13074527 – Vikas Acharya Jun 29 '20 at 05:19
  • 1
    @jessiPP to change programatically, ```var window : Window = window window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) window.statusBarColor = Color.GREEN ``` With this you can change color in each page. This is only for android – Vikas Acharya Jun 29 '20 at 06:01