我想使用react native android制作启动画面

问题描述 投票:1回答:3

Similar to this image

我想使用类似于这个图像的本机android制作启动画面。怎么做?

react-native react-native-android
3个回答
0
投票

尝试使用此react-native-splash-screen库。

按照那里提到的安装说明进行操作。您可以使用这些方法隐藏或显示启动画面。用法:

import SplashScreen from 'react-native-splash-screen'
export default class WelcomePage extends Component {    
        componentDidMount() {
            // do stuff while the splash screen is shown
            // After having done stuff (such as async tasks) hide the splash screen
            SplashScreen.hide();
        }
    }

0
投票

是的,绝对可以使用react-native-splash-screen库。或者您也可以手动添加它们。有关详细信息,请查看此链接https://medium.com/handlebar-labs/how-to-add-a-splash-screen-to-a-react-native-app-ios-and-android-30a3cec835ae


0
投票

您可以为启动画面创建单独的屏幕,您可以在其中检查用户是否已登录,并根据结果导航到特定屏幕

您也可以像这样重置导航堆栈

const loginAction = StackActions.reset({
    index: 0,
    actions: [NavigationActions.navigate({ routeName: 'Login' })],
});

const homeAction = StackActions.reset({
    index: 0,
    actions: [NavigationActions.navigate({ routeName: 'Home' })],
});

派遣使用

if (this.state.loggedIn)
                this.props.navigation.dispatch(homeAction);
            else
                this.props.navigation.dispatch(loginAction);
© www.soinside.com 2019 - 2024. All rights reserved.