小编Gil*_*mon的帖子

如何使用本机反应和反应导航设置背景图像?

我正在使用 React Native 和 React Navigation v3,并且我正在尝试为我的整个应用程序设置背景图像。但由于某种原因,图像没有显示。

如果我包装我的 Home 组件,背景图像将按预期显示,但如果我包装堆栈导航器,则背景为白色。我在网上搜索了解决方案,但似乎不起作用。

const AppNavigator = createAppContainer(
  createStackNavigator(
    {
      Home: {screen: Home},
      Vocabulary: {screen: Vocabulary},
      AddWord: {screen: AddWord},
    },
    {
      initialRouteName: 'Home',
      headerMode: 'none',
      cardStyle: {backgroundColor: 'transparent', shadowColor:'transparent'},
      transitionConfig: () => ({
        containerStyle: {
          backgroundColor: 'transparent',
        },
      }),
    },
 ),
);
const App = () => {
 return (
    <ImageBackground
      source={require('./src/drawable/background1.jpg')}
      style={{flex: 1}}
      resizeMode="cover">
      <Provider store={store()}>
        <AppNavigator />
      </Provider>
    </ImageBackground>
 );
};
export default App;
Run Code Online (Sandbox Code Playgroud)

现在我看到了该组件,但背景是白色的。

react-native react-navigation

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

react-native ×1

react-navigation ×1