Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28476

Change color of statusBar in splashScreen react-native android

$
0
0

enter image description here

I try to add a splash screen to a RN app. As you can see in the gif the status bar color is changing to black while the splash screen is on, but i can't find the problem exactly. I have followed this tutorial to implement the splash screen: Add splash screen to RN app Please find here the code i added to android studio:

in AndroidManifest.xml =>

<activity
            android:name="MainActivity"
            android:label="@string/app_name"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="adjustResize"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:exported="true"
            />

        <activity
            android:name=".SplashActivity"
            android:theme="@style/SplashTheme"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
            </intent-filter>
        </activity>

in styles.xml =>

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->

    <!-- Add the following line to set the default status bar color for all the app. -->
    <item name="android:statusBarColor">@color/mdcGreen</item>
    <!-- Add the following line to set the default status bar text color for all the app
    to be a light color (false) or a dark color (true) -->
    <item name="android:windowLightStatusBar">false</item>
    <!-- Add the following line to set the default background color for all the app. -->
    <item name="android:windowBackground">@drawable/background_splash</item>
</style>

<!-- Adds the splash screen definition -->
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:statusBarColor">@color/mdcGreen</item>
    <item name="android:background">@drawable/background_splash</item>
</style>

</resources>

in drawable/background_splash.xml =>

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:drawable="@color/mdcGreen"/>

    <item
        android:width="200dp"
        android:height="200dp"
        android:drawable="@mipmap/mdc"
        android:gravity="center" />

</layer-list>

in layout/launch_screen.xml =>

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:background="@drawable/background_splash"
    android:statusBarColor="@color/mdcGreen">

</LinearLayout>

THANKS!


Viewing all articles
Browse latest Browse all 28476

Trending Articles