Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 1.46 KB

android.md

File metadata and controls

46 lines (32 loc) · 1.46 KB

Android

Configure

  1. Add a splash drawable to your project. I recommend using 9-png and adding a size for each screen density.

    http://stackoverflow.com/a/34726279

  2. In android/app/src/main/res/values/styles.xml: Adjust your AppTheme and add a windowBackground of the recently added drawable.

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/splash</item>
    </style>
  3. Move your AppTheme from your Application to your Activity ( see https://github.com/mehcode/rn-splash-screen/commit/3cdbb187c38ef8dcc129baef804aed70e2bce0e1 )

  4. In android/app/src/main/java/com/__APPNAMES__/MainActivity.java: Show this (from rn-splash-screen) splash screen and hide the native splash screen (from your modified theme) in onCreate.

    // [...]
    import android.graphics.Color;
    import android.os.Bundle;
    
    import com.facebook.react.ReactInstanceManager;
    import com.facebook.react.bridge.ReactContext;
    import com.mehcode.reactnative.splashscreen.SplashScreen;
    
    public class MainActivity extends ReactActivity {
      // [...]
    
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // Show the js-controlled splash screen
          SplashScreen.show(this, getReactInstanceManager());
    
          super.onCreate(savedInstanceState);
    
          // [...]
      }
    
      // [...]
    }