我想调整 TabBar 的大小,因为默认高度太大,如何实现?谢谢。
DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text('Flutter App'),
bottom: TabBar(
tabs: <Widget>[
Text('Tab 1'),
Text('Tab 2'),
],
),
),
body: TabBarView(
children: <Widget>[
Icon(Icons.apps),
Icon(Icons.apps),
],
),
),
)
Run Code Online (Sandbox Code Playgroud)
对于 TabBar 小部件,您可以按照@praveenb 的建议进行操作
child: TabBar(
...
tabs: [
SizedBox(
height: 100,
child: Tab(
...
Run Code Online (Sandbox Code Playgroud)
小智 6
您可以使用PreferredSize:
DefaultTabController(
length: 2,
child: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(150.0),
child: AppBar(
bottom: TabBar(
tabs: <Widget>[
Text('Tab 1'),
Text('Tab 2'),
],
),
),
),
body: TabBarView(
children: <Widget>[
Icon(Icons.apps),
Icon(Icons.apps),
],
),
),
)
Run Code Online (Sandbox Code Playgroud)
它将更改应用程序栏的整体高度,但如果您想更改选项卡栏的高度,只需将PreferredSize 小部件应用到TabBar 小部件小部件,而不是将其应用到AppBar 小部件。
| 归档时间: |
|
| 查看次数: |
7880 次 |
| 最近记录: |