rn-splash-screen icon indicating copy to clipboard operation
rn-splash-screen copied to clipboard

there is a unknow Gig showing after show the SplashImage

Open Yanzlllll opened this issue 7 years ago • 6 comments

Yanzlllll avatar Jan 26 '18 06:01 Yanzlllll

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();
    }
} 

adderly avatar Feb 02 '18 14:02 adderly

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

mehcode avatar Feb 02 '18 18:02 mehcode

@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?

adderly avatar Feb 02 '18 19:02 adderly

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.

mehcode avatar Feb 02 '18 23:02 mehcode

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.

thinkawitch avatar Apr 23 '18 11:04 thinkawitch

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>

aleafo avatar Nov 26 '18 07:11 aleafo