我想达到这个结果
但这是当前行为
您会注意到,两个Text
组件均未正确对齐。
这是代码
<View style={{ flexDirection: 'row', marginRight: 7, borderWidth: 2 }}>
<Text style={{ color: '#0022FF', fontWeight: 'bold', fontSize: 20, alignSelf: 'flex-end', marginRight: 5 }}>2.6</Text>
<Text style={{ color: '#0022FF', fontSize: 9, alignSelf: 'flex-end' }}>Bar</Text>
</View>
你们可以帮我吗?
答案 0 :(得分:1)
我认为,如果您将两个文本都包装在另一个<Text>
组件中,则应该会起作用:
<View style={{ flexDirection: 'row', marginRight: 7, borderWidth: 2 }}>
<Text>
<Text style={{ color: '#0022FF', fontWeight: 'bold', fontSize: 20, alignSelf: 'flex-end', marginRight: 5 }}>2.6</Text>
<Text style={{ color: '#0022FF', fontSize: 9, alignSelf: 'flex-end' }}>Bar</Text>
</Text>
</View>