【发布时间】:2017-05-21 20:16:43
【问题描述】:
我正在尝试使用 flexbox 将我的图标对齐到按钮视图的左侧,并将文本对齐到中心。目前它们都与中心对齐,但我不确定如何让我的图标位于按钮的最左边缘,同时保持文本在视图中居中
现在我的按钮看起来像这样:
我将https://github.com/APSL/react-native-button 用于按钮和 https://github.com/oblador/react-native-vector-icons 图标
下面是我的一些代码:
<Button style={signupStyles.facebookButton}>
<View style={signupStyles.nestedButtonView}>
<Icon
name="facebook"
size={30}
color={'white'}
/>
<Text style={signupStyles.buttonText}>Continue with Facebook</Text>
</View>
</Button>
var signupStyles = StyleSheet.create({
buttonText: {
color: 'white',
fontWeight: 'bold',
textAlign: 'center',
},
facebookButton: {
backgroundColor: styleConstants.facebookColor,
borderColor: styleConstants.facebookColor,
borderWidth: 2,
borderRadius: 22,
},
nestedButtonView: {
flexDirection: 'row',
alignItems: 'center',
},
});
【问题讨论】:
标签: css react-native flexbox