Jes*_*sse 16 dart material-ui flutter
有没有办法自定义BottomNavigationBar高度?
我目前有一个BottomNavigationBar带有标签的标签可以点击/滑动导航,但是默认高度(即使在减少文本和图标之后)太高了。
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
title: Text( 'RefLog', style: Styles.headerLarge ),
actions: <Widget>[
new IconButton(
icon: Icon(Icons.list),
onPressed: () {},
)
],
),
body: DefaultTabController(
length: 3,
child: Scaffold(
body: TabBarView(
children: _children,
),
bottomNavigationBar: TabBar(
tabs: [
Tab( text: 'One', icon: Icon(Icons.import_contacts, size: 20.0) ),
Tab( text: 'Two', icon: Icon(Icons.restaurant, size: 20.0) ),
Tab( text: 'Three', icon: Icon(Icons.record_voice_over, size: 20.0) ),
],
labelStyle: TextStyle(fontSize: 12.0),
labelColor: Colors.white,
unselectedLabelColor: Colors.white30,
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: Colors.white,
),
backgroundColor: Colors.blue,
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
小智 40
您可以通过 SizedBox 包装 bottomNavigationBar,
bottomNavigationBar: SizedBox(height: 58, child: //some widget )
Run Code Online (Sandbox Code Playgroud)
小智 10
我设置BottomNavigationBar( selectedFontSize: 0.0, unselectedFontSize: 0.0)。然后我用 包裹BottomNavigationBar小部件SizedBox( height: 50)。\n它对我有用。希望它也适用于你们\xe2\x80\xa6
小智 6
我遇到了同样的问题,BottomNavigationBar无法覆盖高度,我的解决方案是使用 调整图标大小SizedBox,它确实降低了高度,其他最终解决方案是更新标题属性的字体大小,这是我的示例:
new BottomNavigationBarItem(
icon:new SizedBox(
child: new IconButton(
icon: new Image.asset("assets/images/icon_ar.png"),
onPressed: () {}),
width: 38,
height: 38,
),
title: new Text("", style: new TextStyle(fontSize: 0),))
Run Code Online (Sandbox Code Playgroud)
这BottomNavigationBar在两个平台上都有一个尺寸标准。
您可以创建自己的小部件
Widget customBottomNavigationBar(BuildContext context){
double myHeight =100.0;//Your height HERE
return SizedBox(
height: myHeight,
width: MediaQuery.of(context).size.width,
child:TabBar(
tabs: [
Tab( text: 'One', icon: Icon(Icons.import_contacts, size: 20.0) ),
Tab( text: 'Two', icon: Icon(Icons.restaurant, size: 20.0) ),
Tab( text: 'Three', icon: Icon(Icons.record_voice_over, size: 20.0) ),
],
labelStyle: TextStyle(fontSize: 12.0),
labelColor: Colors.white,
unselectedLabelColor: Colors.white30,
indicatorSize: TabBarIndicatorSize.label,
indicatorColor: Colors.white,
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
title: Text( 'RefLog', style: Styles.headerLarge ),
actions: <Widget>[
new IconButton(
icon: Icon(Icons.list),
onPressed: () {},
)
],
),
body: DefaultTabController(
length: 3,
child: Scaffold(
body: TabBarView(
children: _children,
),
bottomNavigationBar: customBottomNavigationBar(context),
backgroundColor: Colors.blue,
),
),
);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
39302 次 |
| 最近记录: |