【问题标题】:How to remove the gap above and below the text on flutter如何消除颤动上文本上方和下方的间隙
【发布时间】:2019-05-27 06:20:09
【问题描述】:

我试图将文本“Hello”放在“123”的正下方,但文本越大,差距越大。怎么消除缝隙??? Flutter 图像添加在下面。

【问题讨论】:

  • 如果可以的话,可以给我们看看你的代码吗?
  • 为上面的代码添加了一个链接

标签: text flutter widget padding


【解决方案1】:

到目前为止,我能找到的唯一方法是减少 height 属性,但问题在于它仅减少了上面的差距。因此,在您的情况下,您可以尝试将 hello 文本设置为最小:

Text(
   '123',
    style: TextStyle(fontSize: 60.0),
),
Text(
   'hello',
    style: TextStyle(fontSize: 10.0, height: 0.1),
),

【讨论】:

    【解决方案2】:

    使用Stack 小部件对齐您的文本小部件

    Stack(
          children: <Widget>[
            Text(
              '123',
              style: TextStyle(fontSize: 60.0),
            ),
            Positioned(
              child: Text('Hello'),
              bottom: 0.0,
              left: 35.0,
            )
          ],
        ),
    

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 2016-12-08
      • 1970-01-01
      • 2021-11-30
      • 2018-01-05
      • 2022-07-21
      • 1970-01-01
      • 1970-01-01
      • 2010-10-18
      • 2013-02-15
      相关资源
      最近更新 更多