2017-06-20 74 views
0

我想在StackNavigator中使用图像作为标题的标题。它适用于iOS罚款,但不能让它在Android上工作:如何在Android上的react-navigation标题中将图像设置为标题?

const navigationOptions = { 
    header: ({navigate}) => ({ 
     left: (
      <TouchableOpacity 
       activeOpacity={1} 
       onPress={() => navigate('DrawerOpen')}> 
       <Image 
        style={styles.app_drawer} 
        source={require("../assets/ic_drawer.png")} 
       /> 
      </TouchableOpacity> 
     ), 
     title: (
      <Image 
       style={styles.app_logo} 
       source={require("../assets/ctw_logo_white.png")}/> 
     ), 
     style: {backgroundColor: colors.purple}, 
    }), 
}; 

const Stack = { 
    [strings.route_cases]: { 
     name: "Cases", 
     screen: Object.assign(MainScreen, {navigationOptions}), 
    }, 
    [strings.route_case_details]: { 
     name: "Case Details", 
     screen: CaseDetailsScreen, 
    }, 
}; 

回答

0

尝试这个,,,,

const navigationOptions = { 
     header: ({navigate}) => ({ 
      left: (
<View style={{flexDirection:'row'}}> 
       <TouchableOpacity 
        activeOpacity={1} 
        onPress={() => navigate('DrawerOpen')}> 
        <Image 
         style={styles.app_drawer} 
         source={require("../assets/ic_drawer.png")} 
        /> 
       </TouchableOpacity> 

       <Image 
      style={styles.app_logo} 
      source={require("../assets/ctw_logo_white.png")}/> 
</View> 
      ), 
      title: null, 
      style: {backgroundColor: colors.purple}, 
     }), 
    }; 

    const Stack = { 
     [strings.route_cases]: { 
      name: "Cases", 
      screen: Object.assign(MainScreen, {navigationOptions}), 
     }, 
     [strings.route_case_details]: { 
      name: "Case Details", 
      screen: CaseDetailsScreen, 
     }, 
    }; 

给予marginleft图像,并将其调整

0

原因图像没有显示是我没有提供任何宽度的图像,只要我指定了一个宽度(不只是高度)的图像出现在android ...我还必须动态调整图像显示准确在工具栏的中心。

相关问题