【问题标题】:How to change the alignment of text in an eleveted button in dart如何更改飞镖中提升按钮中文本的对齐方式
【发布时间】:2022-12-10 15:29:15
【问题描述】:

我想改变这个提升按钮中文本的位置,如何使它从中心向右或向左

我尝试使用 TextAlign 但它没有用......

【问题讨论】:

  • 你能提供你尝试过的源代码吗?

标签: flutter dart


【解决方案1】:

您可以为 button 指定 style 并创建所需的 padding

就像下面的例子一样,我从左边设置了padding16从右边0.

ElevatedButton(
  style: ElevatedButton.styleFrom(
        padding: const EdgeInsetsDirectional.only(
          start: 16,
          top: 8,
          end: 0,
          bottom: 8,
        ),
      ),
      child: const Text('Click'),
      onPressed: () {},
    )

结果可以在下图中看到

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-19
    • 2021-12-20
    • 2019-08-18
    • 1970-01-01
    • 2022-06-11
    • 2011-04-06
    • 1970-01-01
    相关资源
    最近更新 更多