mehcode / rn-splash-screen

A JavaScript-controlled splash-screen for React Native designed to be run directly after the native splash-screen.
MIT License
350 stars 95 forks source link

there is a unknow Gig showing after show the SplashImage #60

Open Yanzlllll opened 6 years ago

adderly commented 6 years ago

Same here. There is an image that is being set.

Got the problem here: https://github.com/mehcode/rn-splash-screen/blob/90d45f4f8487f9accbb90ecb4da84f559b815293/android/src/main/java/com/mehcode/reactnative/splashscreen/SplashScreen.java#L31

It should use the theme provided by our activity not the one containing the library, this image is set in the Theme. We could use activity.getTheme();


public class MainActivity extends PreferenceActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Theme theme = this.getTheme();
    }
} 
mehcode commented 6 years ago

If you look at the example application or the android documentation it should explain to override the theme it's using.

adderly commented 6 years ago

@mehcode So, i added the AppTheme as describe in the how to for android.

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowBackground">@drawable/splash</item>
</style>

What i am seeing is that it takes the library provided RNSplashScreen_SplashTheme theme instead of taking the one provided in the user(me) activity . Or am i missing something?

mehcode commented 6 years ago

https://github.com/mehcode/rn-splash-screen/blob/master/android/src/main/res/values/styles.xml#L7 should refer to your drawable/splash if you've defined one correctly.

I've tried running the example app several times and I don't see the default image ( https://github.com/mehcode/rn-splash-screen/blob/master/android/src/main/res/drawable/splash.png ) show up at any point.

Try cloning and running the example. I admit it can be a bit confusing to setup the first time.

thinkawitch commented 6 years ago

I too get this issue with "default" image from module, not my project. I'm not the java developer and might be wrong. Unfortunately I cannot compile example with my android studio 3.1 and react-native-cli: 2.0.1 (error: method show in class SplashScreen cannot be applied to given types)

I checked android setup instuctions twice, seems all made correct. At last I just added my settings into styles.xml as RNSplashScreen_SplashTheme node.

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- android:windowBackground does not get applied from here -->
    </style>
    <style name="RNSplashScreen_SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/background_splash</item>
        <item name="android:statusBarColor">@color/white</item>
    </style>
</resources>

And got my splash screen works as expected.

I used react-native-splash-screen before, but it does not work great with react-native-fcm, and this library rn-splash-screen - works. Thank you for your library.

aleafo commented 5 years ago

I have the same issue. While the example app works fine. The only difference between the example and mine is the theme name. So, I rename the theme name "RNSplashScreen_SplashTheme" and replace it in AndroidManifest.xml, then solve it!

<manifest ...>
    ....
    <application...
        <activity android:theme="@style/RNSplashScreen_SplashTheme" ...

And the /src/res/values/styles.xml

<resources>
    <style name="RNSplashScreen_SplashAnimation">
        <item name="android:windowExitAnimation">@android:anim/fade_out</item>
    </style>
    <style name="RNSplashScreen_SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/launch_screen</item>
        <item name="android:statusBarColor">@color/splashBackground</item>
        <item name="android:windowAnimationStyle">@style/RNSplashScreen_SplashAnimation</item>
    </style>
</resources>