gpt4 book ai didi

text - 文本的第二行不在行的中心呈现

转载 作者:行者123 更新时间:2023-12-04 00:05:42 25 4
gpt4 key购买 nike

我对 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>

enter image description here

最佳答案

您需要使用 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>

关于text - 文本的第二行不在行的中心呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46566130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com