- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在FloatingActionButton
上显示BottomNavigationBar
。我为FloatingActionButton
和BottomNavigationBar
创建了两个单独的小部件。但是当我替换屏幕上的FloatingActionButton
时,它将在BottomNavigationBar
后面
please see below image
FloatingActionButton
上方显示
bottomNavigationBar
。
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: Header().build(context),
backgroundColor: Colors.white,
body: Container(
padding: EdgeInsets.symmetric(horizontal: 20),
child: _widgetOptions.elementAt(_selectedIndex),
),
bottomNavigationBar: BottomNavBar(this._onItemTapped, _selectedIndex)],
);
}
class BottomNavBar extends StatefulWidget {
final Function onItemTapped;
final int selectedIndex;
BottomNavBar(this.onItemTapped,this.selectedIndex);
@override
State<StatefulWidget> createState() {
return _BottomNavBar();
}
}
class _BottomNavBar extends State<BottomNavBar> {
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
currentIndex: widget.selectedIndex,
items: navigationItems,
onTap: (index) {
widget.onItemTapped(index);
},
fixedColor: Theme.of(context).primaryIconTheme.color,
iconSize: 24.0,
type: BottomNavigationBarType.fixed);
}
}
FloatingActionButton
在
Stack
布局内,并且在
BottomNavigationBarItem
内被调用(这是另一个屏幕)
Widget build(BuildContext context) {
return SizedBox(
width: expandedSize,
height: expandedSize,
child: AnimatedBuilder(
animation: _animationController,
builder: (BuildContext context, Widget child) {
return Stack(
alignment: Alignment.center,
children: <Widget>[
_buildExpandedBackground(),
_buildFabCore()
],
);
},
),
);
}
Widget _buildFabCore() {
double scaleFactor = 2 * (_animationController.value - 0.5).abs();
return FloatingActionButton(
onPressed: _onFabTap,
child: Transform(
alignment: Alignment.center,
transform: Matrix4.identity()..scale(1.0, scaleFactor),
child: Icon(
_animationController.value > 0.5 ? Icons.close : Icons.filter_list,
color: Colors.white,
size: 26),
),
backgroundColor: _colorAnimation.value,
);
}
最佳答案
在Scaffold
内部,将属性floatingActionButtonLocation
添加到FloatingActionButtonLocation.endFloat,
或FloatingActionButtonLocation.endDocked
中。endFloat
将在底部导航上方添加FAB。尝试同时应用。
编辑(例如):
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: 'Flutter GTranslate Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyApp(),
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
"https://images.pexels.com/photos/1054289/pexels-photo-1054289.jpeg",
),
fit: BoxFit.cover,
),
),
),
Center(
child: CircularProgressIndicator(backgroundColor: Colors.red,),
),
],
),
bottomNavigationBar: BottomAppBar(
shape: CircularNotchedRectangle(),
notchMargin: 4.0,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
InkWell(
onTap: () {},
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(Icons.person),
Text("Profile"),
],
),
),
InkWell(
onTap: () {},
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(Icons.favorite),
Text("Favorite"),
],
),
),
InkWell(
onTap: () {},
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(Icons.settings),
Text("Settings"),
],
),
),
SizedBox(width: 6.0),
],
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
floatingActionButton: FloatingActionButton(onPressed: () {}, child: Icon(Icons.menu),),
);
}
}
关于android - 如何在bottomNavigationBar顶部显示FloatingActionButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56153266/
如果我正常运行应用程序,应用程序运行良好,但当我尝试测试它时显示错误,这里是错误的完整日志。 java.lang.RuntimeException: android.view.InflateExcep
只是想澄清一个概念上的疑问。 float 操作按钮的 hide() 函数类似于 visibility.GONE 还是 visibility.INVISIBLE? 最佳答案 简而言之:是的。 以下是从设
我在以下布局文件 activity_register 中有一个 float 操作按钮:
我在 CoordinatorLayout 中使用 FloatingActionButton,但与正常行为不同,我想在到达底部时显示它,以便让用户看到更多数据。 为此,我在 Internet 上找到了该
我在使用 FloatingActionButton 时遇到了一些问题,它在模拟器上可以正常工作,但是当我安装到我的手机(Galaxy s4,Android V4.4.4)时它无法正常工作我附上了一些图
我想在 Android 中创建一个类似于 Gmail 收件箱的简单布局。项目列表和用于添加新项目的 FloatingActionButton。在 Android Studio 的设计选项卡中,按钮显示
您好,我正在尝试实现 makovkastar 的 [FloatingActionButton][1] 库。 (因为它是向后兼容的。它适用于单个 FAB,但是当添加 2 个按钮时,“列表”似乎只附加到一
我无法制作正确的按钮。如果我们为 CoordinatorLayout 设置 android: layout_height = "90dp",那么一切都会发生,但我希望它没有硬值。我可以这样做吗?
我正在使用 this library这对于实现带有自定义菜单和许多其他内容的 float 操作按钮来说非常棒。 但是在使用这个库时,我遇到了更改 FloatingActionMenu 中的 Float
我需要创建一个带有白色边框并填充纯色(蓝色或灰色)的 FAB。 xml 我尝试了 How to change android design support library FAB Button bo
我越来越熟悉新的 support.design 库,但我正面临 FloatingActionButton 的这个问题。我试图以编程方式隐藏它,但按钮始终可见。 我觉得 app:layout_ancho
我在 api 21+ 中使用 FloatingActionButton 它显示完全正常,但如果我在 api 20 中查看它- 那么它在后台有四行。 下面是我的FloatingActionButton的
我正在使用 FloatingActionButton 和 OnClick。我想显示 PopupMenu 并使用漂亮的动画(旋转 90 度)旋转相同的 FAB 按钮。 点击时,它应该自己动画: 我能够在
最近我从GitHub下载了一段代码,并同步到我的android studio。这样做时我遇到了很多错误和问题,并以某种方式修复了其中的大部分。但是,我现在遇到的最后一个问题是我的 android st
我正在使用 Android 支持 FloatingActionButton (FAB) 和 CoordinatorLayout,我想将 FAB 锚定到 CardView。 这是我的代码:
我正在尝试在我的应用程序中使用 float 操作按钮 (FAB)。但是,当我声明相同时,我得到了错误: android.support.design.widget.FloatingActionButt
我目前正在开发一个使用 FloatingActionButton 的 Android 应用程序。我想使用快速拨号来执行多个操作,如 this 中所述,旋转/跳出操作按钮。 Google 在 Andro
我找不到获得无边框 FAB 的方法。例如,当我尝试时: 我得到: 请注意 FAB 周围的边界。我已经尝试过 adjustViewBounds="true"和 android:background="
目前正在开发一个应用程序,我需要在 折叠工具栏 的右下角添加“共享”和“添加”按钮(视差效果)。 它可能隐藏在滚动中或可能位于 Actionbar 上。添加了我想要实现的图像。目前不知道如何执行此操作
我正在尝试创建一个带有如下图标的 FloatingActionButton:https://github.com/jd-alexander/LikeButton 如您所见,该按钮是动画,而不仅仅是两个
我是一名优秀的程序员,十分优秀!