Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在React本机应用程序中实现启动屏幕的简单方法_Reactjs_React Native_Splash Screen - Fatal编程技术网

Reactjs 在React本机应用程序中实现启动屏幕的简单方法

Reactjs 在React本机应用程序中实现启动屏幕的简单方法,reactjs,react-native,splash-screen,Reactjs,React Native,Splash Screen,我是一个新的反应本土发展。我尝试在我的应用程序中实现一个启动屏幕。我在网上尝试了很多选项,但没有成功,因为有些代码已经过时,有些过程非常混乱。下面是使用示例代码 import SplashScreen from 'react-native-splash-screen' export default class WelcomePage extends Component { componentDidMount() { // do stuff while splash s

我是一个新的反应本土发展。我尝试在我的应用程序中实现一个启动屏幕。我在网上尝试了很多选项,但没有成功,因为有些代码已经过时,有些过程非常混乱。

下面是使用示例代码

import SplashScreen from 'react-native-splash-screen'

export default class WelcomePage extends Component {

    componentDidMount() {
        // do stuff while splash screen is shown
        // After having done stuff (such as async tasks) hide the splash screen
        SplashScreen.hide();
    }
}
要了解更多信息,请参阅

要使
全屏显示

On MainActivity.java, just like that:

@Override
protected void onCreate(Bundle savedInstanceState) {
    SplashScreen.show(this, R.style.SplashTheme); // Add theme here 
    super.onCreate(savedInstanceState);
}


IN res/values/styles.xml

<resources>

    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
   <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">true</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>

</resources>
MainActivity.java上的
,如下所示:
@凌驾
创建时受保护的void(Bundle savedInstanceState){
SplashScreen.show(this,R.style.SplashTheme);//在此处添加主题
super.onCreate(savedInstanceState);
}
在res/values/styles.xml中
真的
真的
真的
真的
@空的
假的
启动screen.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/launch_screen" android:scaleType="centerCrop" />
</RelativeLayout>

我推荐,因为它仍在积极维护中。
在实现任何要求您向Swift和javabridge文件添加代码的库之前,最好先熟悉RN文件夹结构。一旦您了解了文件夹结构和一些主要文件,调试应用程序就变得容易多了,您将能够更快地开发应用程序。

如果您搜索了react native splashscreen,您将获得react native splashscreen的软件包和最新代码。这对你也不起作用吗?你能确认我这是软件包吗:这是我去年3月在我的RN应用程序中添加闪屏时遵循的教程。有没有办法全屏显示启动画面?有没有办法全屏显示启动画面?是的,我已经更新了答案,请检查我尝试了你的代码,但没有成功。链接:如果有帮助,请检查我的更新答案