react-native - 如何在 RN 中的视图末尾放置 2 个文本组件?
问题描述
我想达到这个结果
但这是当前的行为
您可以注意到两个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>
你们能帮我解决这个问题吗?
解决方案
我认为如果您将两个文本都包装在另一个<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>
推荐阅读
- php - 升级后,Magento 2.4.2 显示空白结帐表
- grails - 仅在生产环境中编码的 Grails GSP 表达式
- java - 如何使用 if 语句检查数组是否不包含值
- reactjs - 我是否需要手动定义 onChange 处理程序来填充状态变量?
- c++ - 在 QTableWidget 中显示项目
- javascript - 如何使用适用于 Javascript 的 Azure Core Logger 启用信息日志记录?
- jupyter-notebook - 如何删除
- android - 如何在 Android NDK cpp 文件中包含 linux 头文件?
- php - 在 Azure 上的 PHP 7.4 中启用无扩展名的文件服务
- ios - 当 UIImagepicker 裁剪视频时,是否可以以秒为单位显示视频时间,当我单击一次选择时,我可以返回裁剪屏幕吗?