2017-06-20 67 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 ...我還必須動態調整圖像顯示準確在工具欄的中心。

相關問題