Flutter——FloatingActionButton组件(浮动按钮组件)
| 属性名称 | 属性值 |
|
child
|
子视图,一般为 Icon,不推荐使用文字
|
|
tooltip
|
FAB 被长按时显示,也是无障碍功能
|
|
backgroundColor
|
背景颜色
|
|
elevation
|
未点击的时候的阴影
|
|
hignlightElevation
|
点击时阴影值,默认 12.0
|
|
onPressed
|
点击事件回调
|
|
shape
|
可以定义 FAB 的形状等
|
|
mini
|
是否是 mini 类型默认 false
|
FloatingActionButton实现闲鱼APP底部凸起按钮:

import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: "FloatingActionButton",
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int _currentIndex = 0;
List _pageList = [
Page("闲鱼页面"),
Page("鱼塘页面"),
Page("发布页面"),
Page("消息"),
Page("我的")
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: _pageList[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed,
fixedColor: Colors.yellow,
onTap: (int index) {
setState(() {
this._currentIndex = index;
});
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text("闲鱼", style: TextStyle(color: Colors.black54))),
BottomNavigationBarItem(
icon: Icon(Icons.category),
title: Text("鱼塘", style: TextStyle(color: Colors.black54))),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
title: Text("发布", style: TextStyle(color: Colors.black54))),
BottomNavigationBarItem(
icon: Icon(Icons.message),
title: Text("消息", style: TextStyle(color: Colors.black54))),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
title: Text("我的", style: TextStyle(color: Colors.black54))),
],
),
floatingActionButton: Container(
margin: EdgeInsets.only(top: 5),
child: FloatingActionButton(
child: Icon(Icons.add, color: Colors.black54),
backgroundColor: Colors.yellow,
onPressed: () {
setState(() {
this._currentIndex = 2;
});
},
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
);
}
}
class Page extends StatelessWidget {
String text;
Page(this.text);
@override
Widget build(BuildContext context) {
return Center(
child: Text(text),
);
}
}
Flutter——FloatingActionButton组件(浮动按钮组件)的更多相关文章
- Flutter中的浮动按钮FloatingActionButton 及融合底部工具栏
FloatingActionButton 简称 FAB,从字面理解可以看出,它是“可交互的浮动按钮”,其实在Flutter默认生成的代码中就有这家伙,只是我们没有正式的接触. 一般来说,它是一个圆形, ...
- Flutter中的浮动按钮 FloatingActionButton
FloatingActionButton 简称 FAB ,可以实现浮动按钮,也可以实现类似闲鱼 app 的底部凸起导航 . 常用属性 FloatingActionButton的常用属性,同flutte ...
- "浮动按钮"组件:<fab> —— 快应用组件库H-UI
    <import name="fab" src="../Common/ui/h-ui/basic/c_fab"></import ...
- Flutter学习笔记(11)--文本组件、图标及按钮组件
如需转载,请注明出处:Flutter学习笔记(10)--容器组件.图片组件 文本组件 文本组件(text)负责显示文本和定义显示样式,下表为text常见属性 Text组件属性及描述 属性名 类型 默认 ...
- Flutter 中的常见的按钮组件 以及自定义按钮组件
Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton. IconButton.OutlineButton.ButtonBar.Float ...
- flutter中的按钮组件
Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton.IconButton.OutlineButton.ButtonBar.Floati ...
- 【Flutter学习】基本组件之基本按钮组件
一,概述 由于Flutter是跨平台的,所以有适用于Android和iOS的两种风格的组件.一套是Google极力推崇的Material,一套是iOS的Cupertino风格的组件.无论哪种风格,都是 ...
- Flutter 中的常见的按钮组件 以及自 定义按钮组件
一.Flutter 中的按钮组件介绍 Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton. IconButton.Outlin ...
- Flutter中的按钮组件介绍
Flutter 里有很多的 Button 组件很多,常见的按钮组件有:RaisedButton.FlatButton.IconButton.OutlineButton.ButtonBar.Floati ...
随机推荐
- JS中的match和test正则表达式验证密码或用户名的一种规则
match语法:字符串.match(正则表达式)有符合的:返回符合的数组无符合的:返回null test语法:正则表达式.test(字符串)有符合的:返回true无符合的 :返回false 该文的密码 ...
- 超文本css样式换行
之前有关于LODOP中纯文本换行的相关博文:Lodop纯文本英文-等符号自动换行问题纯文本的遇到不拆分的单词的时候,可以通过LODOP 语句设置允许标点溢出,且英文单词拆开.超文本需要通过css样式控 ...
- Egg.js中使用sequelize事务
对数据库的操作很多时候需要同时进行几个操作,比如需要同时改动几张表的数据,或者对同一张表中不同行(row)或列(column)做不同操作,比较典型的例子就是用户转账问题(A账户向B账号汇钱): 1 从 ...
- CountDownLatch和CyclicBarrier使用上的区别
一.CountDownLatchDemo package com.duchong.concurrent; import java.util.Map; import java.util.concurre ...
- 【网络开发】winsock组播
https://my.oschina.net/lopo/blog/260685 //客户端 #include <winsock2.h> #include <stdio.h> # ...
- C# RESTful API
C# RESTful API REST 全称是 Representational State Transfer,有人说它是一种风格,并非一种标准,个人觉得挺有道理.它本身并没有创造新的技术.组件与服务 ...
- ubuntu18.10 修改MySQL编码为utf-8
首先登陆mysql的交互shell,输入下面的命令查看当前数据库的编码方式 show variables like '%character%'; 从上面可以看出,mysql数据库装上之后初始并不均是u ...
- LeetCode 581. 最短无序连续子数组(Shortest Unsorted Continuous Subarray)
581. 最短无序连续子数组 581. Shortest Unsorted Continuous Subarray 题目描述 给定一个整型数组,你需要寻找一个连续的子数组,如果对这个子数组进行升序排序 ...
- IDE集成开发环境(pycharm)、基本数据类型、用户的交互、运算符
一.IDE集成开发系统pycharm 目的:让Python编程更方便.高效. pycharm的简单定义: PyCharm是一种Python IDE,带有一整套可以帮助用户在使用Python语言开发时提 ...
- 【dfs】Sequence Decoding
Sequence Decoding 题目描述 The amino acids in proteins are classified into two types of elements, hydrop ...