React-native-splash-screen: Issue in splash screen

Created on 11 Mar 2020  Â·  2Comments  Â·  Source: crazycodeboy/react-native-splash-screen

I am facing a one issue with my splash screen. Actually everything works fine but i dont know where i am making a issue and that's a point of my mistake.

  1. My drawable folder having splash.png and background_splash.xml (resource file)

[](

<item android:drawable="@color/blue"/>
<item
    android:drawable="@drawable/splash"
    android:width="300dp"
    android:height="300dp"
    android:gravity="center"
    />

)

2 Layout folder having launch_screen.xml

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

    <!--<ImageView
       android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/splash"
        android:scaleType="centerCrop"
    />//-->

</LinearLayout>
  1. Values folder having colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="blue">#4F6D7A</color>
    <color name="primary_dark">#4F6D7A</color>
</resources>

4 Values folder having styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:textColor">#000000</item>
        <item name="android:windowFullscreen">true</item>
    </style>

    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@drawable/background_splash</item>
    <item name="android:windowFullscreen">true</item>
    </style>
</resources>

  1. My manifest file having
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.kikleeapp">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:theme="@style/AppTheme">


       <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" />

    </intent-filter>
</activity>


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

      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>
  1. Mainactivity.java
package com.kikleeapp;

import com.facebook.react.ReactActivity;
import android.os.Bundle; // here
import org.devio.rn.splashscreen.SplashScreen; // here

public class MainActivity extends ReactActivity {

  @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this, true);
        super.onCreate(savedInstanceState);
    }


  protected String getMainComponentName() {
    return "kikleeapp";
  }
}

  1. SplashActivity.java
package com.kikleeapp;

import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }
}

This is the complete code which works very well. But what is happening in this it goes first to the background_splash.xml and then goes to launch_screen.xml.

My background splash works very well when it reach to launch_screen.xml. But initially it calls the background_splash.xml where the background image is very small.

Most helpful comment

:) i tried it that way also but not working. But it is fix with another plugin react-native-bootsplash. And it is working very smoothly.

All 2 comments

@wontone18 Hi~~
Maybe try this:

styles

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <!-- <item name="android:windowIsTranslucent">true</item> -->
        <item name="android:windowIsTranslucent">false</item>
        <item name="android:windowDisablePreview">true</item> 
        <item name="android:textColor">#000000</item>
    </style>
</resources>

colors

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="primary_dark">#000000</color>
</resources>

:) i tried it that way also but not working. But it is fix with another plugin react-native-bootsplash. And it is working very smoothly.

Was this page helpful?
0 / 5 - 0 ratings