【问题标题】:How to set size to FloatingActionButton - Flutter如何将大小设置为 FloatingActionButton - Flutter
【发布时间】:2021-04-09 15:20:17
【问题描述】:

我想让按钮变大。卡片小部件中的按钮,它位于对齐标签中..

Align(
    alignment: Alignment(0.9, 0.9),
    heightFactor: 0.0,
    child: FloatingActionButton(
        onPressed: null,
        child: Icon(Icons.share),
    ),
),

【问题讨论】:

  • 您的问题已经在这篇文章中得到解答:stackoverflow.com/questions/52786652/…
  • 这个宽度和高度在Align标签中不接受..如何实现?
  • 好的。我找到了解决方案。非常感谢你

标签: flutter user-interface mobile-application


【解决方案1】:

您需要将 FloatingActionButton 包装在 Container 中,并使用 size 元素管理 Icon 的大小:

     Align(
        alignment: Alignment.center,
        child: Container(
          width: 100,
          height: 200,
          child: FloatingActionButton(
            onPressed: null,
            child: Icon(
              Icons.share,
              size: 80,
            ),
          ),
        ),
      ),

【讨论】:

    【解决方案2】:
    Align(
       alignment: Alignment(0.9, 0.9),
       heightFactor: 0.0,
       child: Container(
            height: MediaQuery.of(context).size.width * 0.2,
            width: MediaQuery.of(context).size.width * 0.2,
            child: FloatingActionButton(
                   onPressed: () {},
                   child: Icon(
                     Icons.share,
                   ),
            ),
         ),
    ),
    

    【讨论】:

      猜你喜欢
      • 2019-10-09
      • 1970-01-01
      • 1970-01-01
      • 2019-01-24
      • 1970-01-01
      • 1970-01-01
      • 2019-03-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多