1 回答

TA贡献1798条经验 获得超7个赞
实际上,一旦您已经声明justifyContent在centerparent 中View,这就会影响 child 的其余部分Views拥有此样式道具。justifyContent您可以做的是在第二个View外壳中替换您的Text和Icon组件alignItems。这应该在您的父母提供的空间中垂直对齐它们View。
height此外,您可以在父级View和textAlignVertical中设置约束Text以更好地对齐。
<View style={{justifyContent: 'center', height: 60}}>
<View style={{display: 'flex', flexDirection: 'row', alignItems: 'center'}}>
<Text style={{fontSize: 18, textAlignVertical: 'center', fontWeight: 'bold'}}>12 Mouses</Text>
<View style={{flexGrow: 1}} />
<Button
buttonStyle={styles.localize}
icon={<Icon name="md-locate" color={'white'} size={28} style={{alignSelf: 'center'}}/>}
onPress={() => {}}
/>
</View>
<View
style ={{
borderWidth: 0.5,
borderColor:'grey',
margin:2,
}}
/>
</View>
添加回答
举报