Javascript 在React Native中设置标题样式的问题

Javascript 在React Native中设置标题样式的问题,javascript,react-native,Javascript,React Native,我的标题是用CSS和HTML编写的,我正在尝试用react native,但似乎position:'absolute'会从场景中删除我的图标 因此,在我的react native应用程序中,我有以下标记: <View style={header}> <TouchableWithoutFeedback onPress={this.props.callback}> <View> <Image

我的标题是用CSS和HTML编写的,我正在尝试用react native,但似乎
position:'absolute'
会从场景中删除我的图标

因此,在我的react native应用程序中,我有以下标记:

<View
   style={header}>

      <TouchableWithoutFeedback
         onPress={this.props.callback}>

      <View>
        <Image
          style={headerIcon}
          source={require('./img/back.png')} />
      </View>
   </TouchableWithoutFeedback>

   <Text style={headerTitle}>{this.props.title.toUpperCase()}</Text>
</View>
有人能告诉我如何使react native头的样式看起来像吗?

试试这个

<View style={styles.header}>

    <TouchableWithoutFeedback
        onPress={this.props.callback}>
        <View>
            <Image
                style={styles.headerIcon}
                source={require('./img/back.png')} />
        </View>
    </TouchableWithoutFeedback>

    <View style={styles.headerTitleWrapper}><Text style={styles.headerTitle}>MY TITLE</Text></View>
</View>
在上检查此项


如果不设置
位置:绝对
,它会做什么?也许是截图?谢谢嘿@BradBumbalough,所以如果我设置position:absolute,图标将不再显示,比如visibility:hidden应该是吗?@BigPun86我正在使用es6解构对象,比如const{header}=style,它与const header=style相等。headerOh抱歉,我的错了:PHey@Faheem,谢谢你的答案,但是如果你看到下面的截图,你可以看到文本不在中间,这就是为什么我想要的位置:绝对-但是,如果没有任何其他解决方案,我可以添加左撇子:图标的边缘和PADIGRIGHT:图标的边缘+图标宽度
<View style={styles.header}>

    <TouchableWithoutFeedback
        onPress={this.props.callback}>
        <View>
            <Image
                style={styles.headerIcon}
                source={require('./img/back.png')} />
        </View>
    </TouchableWithoutFeedback>

    <View style={styles.headerTitleWrapper}><Text style={styles.headerTitle}>MY TITLE</Text></View>
</View>
const styles = StyleSheet.create({

    header: {
        height: 55,
        alignItems: 'center',
        backgroundColor: "#fff",
        flexDirection: 'row'
    },

    headerTitleWrapper: {flex: 1,
        justifyContent: 'center', 
        alignItems: 'center'
    },

    headerTitle: {
        color: 'black',
        fontFamily: 'Dosis',
        fontSize: 15
    },

    headerIcon: {
        width: 22,
        height: 16
    }
})