createMaterialTopnavigator React Navigation v5

时间:2020-04-07 17:35:00

标签: react-native-android react-navigation react-navigation-v5

在两个屏幕之间滑动时,materialTopNavigator中的屏幕之间出现白色闪烁。有一个抽屉式导航器,它嵌套一个堆栈导航器,而该堆栈式导航器又嵌套了标签式导航器。

TabView代码(发生flickr的位置)

const TabView = createMaterialTopTabNavigator();
export const MyTabView = props => {
  return (
    <TabView.Navigator
      initialLayout={{ width: Dimensions.get('window').width, backgroundColor: '#121212' }}
      tabBarOptions={{
        activeTintColor: '#FF8458',
        inactiveTintColor: '#FF845840',
        labelStyle: {
          fontSize: 12,
          fontStyle: 'italic',
          fontWeight: 'bold'
        },
        style: { backgroundColor: '#361B0F' },
        indicatorStyle: { backgroundColor: '#FF845880' }
      }}
    >
      <TabView.Screen name="Movies" component={DashBoard} />
      <TabView.Screen name="TVShows" component={TvShowTab} />
    </TabView.Navigator>
  );
}

1 个答案:

答案 0 :(得分:0)

通过在materialTopNavigator的sceneContainerStyle道具中传递背景色,可以固定90%的闪烁。

export const MyTabView = props => {
  return (
    <TabView.Navigator
      initialLayout={{ width: Dimensions.get('window').width, backgroundColor: '#121212' }}
      sceneContainerStyle={{
        backgroundColor: '#361B0F',
      }}
      tabBarOptions={{
        activeTintColor: '#FF8458',
        inactiveTintColor: '#FF845840',
        labelStyle: {
          fontSize: 12,
          fontStyle: 'italic',
          fontWeight: 'bold'
        },
        tabStyle: {

        },
        style: { backgroundColor: '#361B0F', },
        indicatorStyle: { backgroundColor: '#FF845880' }
      }}
    >
      <TabView.Screen name="Movies" component={DashBoard} />
      <TabView.Screen name="TVShows" component={TvShowTab} />
    </TabView.Navigator>
  );
}//MyTabView