我的 样式有问题Text,我有两行 ,Text文本的第一行在行的中心显示正确,但代码的第二行不在中心。如何解决?
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', flexDirection: 'row' }}>
<Text
style={{ marginLeft: 5, fontWeight: '500', fontFamily: 'Arial', fontSize: ratio * 14, color: '#3c3c3c' }}
numberOfLines={2} > {title}
</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
你需要使用textAlign:'center',
<View
style={{
flex: 1,
justifyContent: "center",
alignItems: "center",
flexDirection: "row"
}}
>
<Text
style={{
textAlign:'center', //Added
marginLeft: 5,
fontWeight: "500",
fontFamily: "Arial",
fontSize: ratio * 14,
color: "#3c3c3c"
}}
numberOfLines={2}
>
{title}
</Text>
</View>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1802 次 |
| 最近记录: |