React-native-splash-screen: [Android Question]: Set navigation bar background color?

Created on 19 Nov 2019  Â·  4Comments  Â·  Source: crazycodeboy/react-native-splash-screen

Hello.

We are simply trying to figure out how to change the background color of the soft keys/navigation bar at the bottom of some android phones (the virtual back button/home/app stack... etc).

I'm assuming it's an easy solution but we can't find documentation anywhere, thanks!

Most helpful comment

Okay, I found it.

styles.xml:

<resources>
    <!-- Base application theme -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@color/backgroundColor</item>
        <item name="android:statusBarColor">@color/backgroundColor</item>
        <item name="android:navigationBarColor">@color/backgroundColor</item>
        <item name="colorControlActivated">@color/blue</item>
    </style>
    <style name="SplashScreenTheme" parent="SplashScreen_SplashTheme">
        <item name="colorPrimaryDark">@color/backgroundColor</item>
        <item name="android:navigationBarColor">@color/backgroundColor</item>
    </style>
</resources>

Add R.style.SplashScreenTheme in MainActivity.java:

SplashScreen.show(this, R.style.SplashScreenTheme);

All 4 comments

@loudy thanks for that but how are you setting the color on the launch screen?

@loudy

Hello guys. Because of that I can't set my background color....

I have:

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
         ...
        <item name="android:navigationBarColor">@color/backgroundColor</item>
    </style>
</resources>

and it works. But while I see SPLASH SCREEN – react-native-splash-screen makes navigation bar BLACK.

How to set color for splash screen?

Okay, I found it.

styles.xml:

<resources>
    <!-- Base application theme -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@color/backgroundColor</item>
        <item name="android:statusBarColor">@color/backgroundColor</item>
        <item name="android:navigationBarColor">@color/backgroundColor</item>
        <item name="colorControlActivated">@color/blue</item>
    </style>
    <style name="SplashScreenTheme" parent="SplashScreen_SplashTheme">
        <item name="colorPrimaryDark">@color/backgroundColor</item>
        <item name="android:navigationBarColor">@color/backgroundColor</item>
    </style>
</resources>

Add R.style.SplashScreenTheme in MainActivity.java:

SplashScreen.show(this, R.style.SplashScreenTheme);
Was this page helpful?
0 / 5 - 0 ratings