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',
},
});
당신은에 아이콘을 설정 할 수있는 width
텍스트를 제공 padding-right
, text-align
및flex:1
<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',
},
iconLeft: {
width: '40px',
},
buttonText: {
flex: 1,
paddingRight: '40px',
textAlign: 'center',
},
});
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다