android - 具有FAB风格的自定义按钮

标签 android flutter button dart

我想制作一组像FAB按钮一样具有波纹效果,高程和形状的按钮。我读到我每个屏幕只能使用一个FAB按钮,因此我需要创建自己的屏幕,而不是使用一组FAB按钮。 The icons design

如何达到效果?是否可以将FAB代码修改为此?

最佳答案

因此,如果您希望晶圆厂以垂直顺序排列,则将它们包装在中,如下所示

class RandomFabScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          FloatingActionButton(
            child: Icon(Icons.home, color: Colors.white,),
            onPressed: (){},
            backgroundColor: Colors.cyan,
          ),
          SizedBox(height: 10,),
          FloatingActionButton(
            child: Icon(Icons.playlist_play, color: Colors.white,),
            onPressed: (){},
            backgroundColor: Colors.red,
          ),
          SizedBox(height: 10,),
          FloatingActionButton(
            child: Icon(Icons.person, color: Colors.white,),
            backgroundColor: Colors.yellow,
            onPressed: (){},
          ),
          SizedBox(height: 10,),
          FloatingActionButton(
            child: Icon(Icons.warning, color: Colors.white,),
            onPressed: (){},
            backgroundColor: Colors.blue,
          ),
        ],
      ),
    );
  }
}

输出enter image description here:

如果要按水平顺序排列它们,请将其包装在

像这样
class RandomFabScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: Row(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          FloatingActionButton(
            child: Icon(Icons.home, color: Colors.white,),
            onPressed: (){},
            backgroundColor: Colors.cyan,
          ),
          SizedBox(width: 10,),
          FloatingActionButton(
            child: Icon(Icons.playlist_play, color: Colors.white,),
            onPressed: (){},
            backgroundColor: Colors.red,
          ),
          SizedBox(width: 10,),
          FloatingActionButton(
            child: Icon(Icons.person, color: Colors.white,),
            backgroundColor: Colors.yellow,
            onPressed: (){},
          ),
          SizedBox(width: 10,),
          FloatingActionButton(
            child: Icon(Icons.warning, color: Colors.white,),
            onPressed: (){},
            backgroundColor: Colors.blue,
          ),
        ],
      ),
    );
  }
}

输出:
enter image description here

关于android - 具有FAB风格的自定义按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60878388/

相关文章:

android - 如何将Android 4 按钮样式移植到低平台?

python - 如何使 python tkinter 匹配按钮到操作系统

android - 如何打开APK文件并安装?

android - 无法在 Activity 中全屏显示日期选择器

java - 使用 getPlacemarks 迭代 KML

Flutter:如何使GridView行高包裹内容?

flutter - 折叠卡片效果 - Flutter

java - Android 应用程序抛出 Guice 异常

android-studio - Flutter:如何将值从streamprovider/listview构建器传递到另一个类

android - 单击/聚焦时如何更改按钮的背景图像?