如何将文本与另一个角色的顶部结合?
我想将一组数字与另一组数字的顶部保持一组,就像在某些价格标签上可以找到的最小货币单位一样。
我已经放置了两个text
在行
中, crossaxisalignment.start
,但我无法让它们两个是相同的高度。
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'409',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
Text(
'00',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
]
)
I would like to align one set of numbers to the top of another set of numbers, just as the smallest currency units that can be found on some price tags.
I've placed two Text
inside a Row
with CrossAxisAlignment.start
but I can't get them both to be the same height.
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'409',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
Text(
'00',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
]
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要为其使用
RichText
。您可以使用widgetspan
将文本对齐到顶部。您可以从下面的示例代码中获取参考:
输出如下:
You need to use
RichText
for it. You can useWidgetSpan
to align the text to the top.You can take reference from the sample code below:
And output is below:
它导致
文本
小部件具有填充。如果键入以下类似的字符,则需要填充。可能这不是实现您想要的最佳实践。您可以通过将
高度
设置为0.8
或其他值来尝试此代码。It caused
Text
widget has padding. The padding is needeed if you type some character like below.May this is not the best practice to achieve what you want. You can try this code by setting
height
to0.8
or other value.