有没有办法自定义 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,
),
),
);
}
最佳答案
你可以通过 SizedBox 包装 bottomNavigationBar,
bottomNavigationBar: SizedBox(height: 58, child: //some widget )
关于 flutter/Dart : Customize Bottom Navigation Bar height,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53758698/