dv3*_*dv3 18 javascript css text react-native
我很反应原生的css-styling ..并且有以下代码:
<Text>
<Text style={(styles.author, { textAlign: "left" })}>
{question.view_count + " views\t" + question.comment_count}
{question.comment_count > 1 || question.comment_count == 0
? " comments"
: " comment"}
</Text>
<Text style={{ textAlign: "right" }}>
{question.solution_count > 0
? question.solution_count + " solutions"
: " Solve this"}
</Text>
</Text>;
Run Code Online (Sandbox Code Playgroud)
问题是第二个"textAlign:'right'"不起作用 - 文本仍在左侧.我希望文本在同一行,但(显然)右边的第二个文本对象.
任何提示?谢谢!
Mih*_*hir 51
我现在无法确认,但你可以尝试一下吗?
{textAlign: 'right', alignSelf: 'stretch'}
如果有效,请告诉我.
UPDATE
我能建议一个解决方法吗?
<View style={{flex: 1, flexDirection: 'row'}}>
<View style={{flex: 1}}>
<Text>4 Views 0 Comments</Text>
</View>
<View style={{flex: 1}}>
<Text style={{textAlign: 'right'}}>Solve This</Text>
</View>
</View>
Run Code Online (Sandbox Code Playgroud)
您可以使用以下代码片段在视图右侧对齐文本:
<View style={{justifyContent: 'space-between'}}>
<Text style={{alignSelf: 'flex-end'}}> Hello </Text>
</View>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
41803 次 |
| 最近记录: |