如何在 Flutter 中将 AppBar 标题放在左侧
How To Place AppBar Title in Left Side in Flutter
这是我的 AppBar Tittle 代码,但它不起作用
Widget build(BuildContext context){
return new Scaffold(
appBar: new AppBar(
title: new Padding(
padding: const EdgeInsets.only(left: 20.0),
child: new Text("App Name"),
),
),
);}
AppBar 标题默认居中。要在左侧显示文本,您应该将 属性 centerTitle 设置为 false,如下所示:
Widget build(BuildContext context){
return new Scaffold(
appBar: new AppBar(
centerTitle: false
title: new Padding(
padding: const EdgeInsets.only(left: 20.0),
child: new Text("App Name"),
),
),
);
}
Transform 是用于在 x-y-z 维度上强制转换小部件的小部件。
return Scaffold(
appBar: AppBar(
centerTitle: false,
titleSpacing: 0.0,
title: Transform(
// you can forcefully translate values left side using Transform
transform: Matrix4.translationValues(-20.0, 0.0, 0.0),
child: Text(
"HOLIDAYS",
style: TextStyle(
color: dateBackgroundColor,
),
),
),
),
);
只需在 AppBar 小部件中将 centerTile
属性 设置为 false
。
AppBar(
...
centerTitle: false,
title: Text("App Name"),
...
)
将 centerTitle
属性 设置为 false。
将 centerTile 属性 设置为 false 并在 AppBar
中将 leadingWidth: 0
如果你想在应用栏的最左边显示标题
Widget build(BuildContext context){
return new Scaffold(
appBar: new AppBar(
centerTitle: false,
leadingWidth: 0, // this is also im
title: new Padding(
padding: const EdgeInsets.only(left: 25.0),
child: new Text("App Name"),
),
),
);
}
将强制文本位于应用栏的最左侧
appBar: AppBar(
centerTitle: false,
backgroundColor: Color(0xff98A8D0),
title: Image.asset(
'assets/covalent_dark_icon.png',
height: 45,
width: 120,
),
)
这才是真正的方法。使用 Transform 会降低您的 UI 响应速度。
这是我的 AppBar Tittle 代码,但它不起作用
Widget build(BuildContext context){
return new Scaffold(
appBar: new AppBar(
title: new Padding(
padding: const EdgeInsets.only(left: 20.0),
child: new Text("App Name"),
),
),
);}
AppBar 标题默认居中。要在左侧显示文本,您应该将 属性 centerTitle 设置为 false,如下所示:
Widget build(BuildContext context){
return new Scaffold(
appBar: new AppBar(
centerTitle: false
title: new Padding(
padding: const EdgeInsets.only(left: 20.0),
child: new Text("App Name"),
),
),
);
}
Transform 是用于在 x-y-z 维度上强制转换小部件的小部件。
return Scaffold(
appBar: AppBar(
centerTitle: false,
titleSpacing: 0.0,
title: Transform(
// you can forcefully translate values left side using Transform
transform: Matrix4.translationValues(-20.0, 0.0, 0.0),
child: Text(
"HOLIDAYS",
style: TextStyle(
color: dateBackgroundColor,
),
),
),
),
);
只需在 AppBar 小部件中将 centerTile
属性 设置为 false
。
AppBar(
...
centerTitle: false,
title: Text("App Name"),
...
)
将 centerTitle
属性 设置为 false。
将 centerTile 属性 设置为 false 并在 AppBar
中将 leadingWidth: 0如果你想在应用栏的最左边显示标题
Widget build(BuildContext context){
return new Scaffold(
appBar: new AppBar(
centerTitle: false,
leadingWidth: 0, // this is also im
title: new Padding(
padding: const EdgeInsets.only(left: 25.0),
child: new Text("App Name"),
),
),
);
}
将强制文本位于应用栏的最左侧
appBar: AppBar(
centerTitle: false,
backgroundColor: Color(0xff98A8D0),
title: Image.asset(
'assets/covalent_dark_icon.png',
height: 45,
width: 120,
),
)
这才是真正的方法。使用 Transform 会降低您的 UI 响应速度。