【发布时间】:2018-03-10 06:02:27
【问题描述】:
我是 react native 的新手,我试图将后退按钮向左对齐,但将标题保持在中心,但没有任何效果,这是代码。
TouchableOpacity 是返回按钮,Text 是标题,每个都有自己的风格。
import React, { Component } from 'react';
import { View, Text, TouchableOpacity, Image } from 'react-native';
import { Colors } from '../Variables';
class Header extends Component {
render(){
return(
<View style={ styles.headerStyle }>
<TouchableOpacity>
<Image style={ styles.backBtnStyle } source={ require('../graphics/icons/arrow_left_white.png') }/>
</TouchableOpacity>
<Text style={ styles.titleStyle }>
TITLE
</Text>
</View>
);
}
}
const styles = {
headerStyle: {
backgroundColor: Colors.primary,
flexDirection: 'row',
alignItems: 'center',
},
backBtnStyle: {
width: 25,
height: 25,
margin: 10,
},
titleStyle: {
color: '#fff',
textAlign: 'center',
fontSize: 25,
}
};
export default Header;
感谢您的帮助。
【问题讨论】:
标签: javascript reactjs react-native flexbox babeljs