对齐问题 Appbar
Alignment Issue Appbar
如何将名称放在靠近 "Welcome Back" 文本的位置?我尝试使用 centerTitle: true 和 textAlign: TextAlign.center 来做到这一点,但到目前为止还没有成功?我错过了什么?
return new Scaffold(
appBar: new AppBar(
brightness: Brightness.light,
backgroundColor: Colors.white,
elevation: 0,
centerTitle: true,
title: Text(
"Welcome Back,",
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(49, 39, 79, 1),
fontWeight: FontWeight.bold,
fontSize: 20),
),
actions: <Widget>[
Row(
children: <Widget>[
Container(
child: Text(name,
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(49, 39, 79, 1),
fontWeight: FontWeight.bold,
fontSize: 20))),
只需在 Padding()
中自定义 left:
:
actions: <Widget>[
Row(
children: <Widget>[
Container(
child: Text(name, style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20))
),
/// Play with the parameter `left: ...`
Padding(padding: const EdgeInsets.only(left: 30, right: 8.0, top: 8.0, bottom: 8.0),
child: CircleAvatar(
backgroundImage: NetworkImage(imageUrl)),
),
],
),
]
另一个解决方案:在AppBar-Title中使用变量name
:
title: Text("Welcome Back, $name", style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20),),
actions: <Widget>[
Row(
children: <Widget>[
/// Play with the parameter `left: ...`
Padding(padding: const EdgeInsets.only(left: 30, right: 8.0, top: 8.0, bottom: 8.0),
child: CircleAvatar(
backgroundImage: NetworkImage(imageUrl)),
),
],
),
]
结果:
如何将名称放在靠近 "Welcome Back" 文本的位置?我尝试使用 centerTitle: true 和 textAlign: TextAlign.center 来做到这一点,但到目前为止还没有成功?我错过了什么?
return new Scaffold(
appBar: new AppBar(
brightness: Brightness.light,
backgroundColor: Colors.white,
elevation: 0,
centerTitle: true,
title: Text(
"Welcome Back,",
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(49, 39, 79, 1),
fontWeight: FontWeight.bold,
fontSize: 20),
),
actions: <Widget>[
Row(
children: <Widget>[
Container(
child: Text(name,
textAlign: TextAlign.center,
style: TextStyle(
color: Color.fromRGBO(49, 39, 79, 1),
fontWeight: FontWeight.bold,
fontSize: 20))),
只需在 Padding()
中自定义 left:
:
actions: <Widget>[
Row(
children: <Widget>[
Container(
child: Text(name, style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20))
),
/// Play with the parameter `left: ...`
Padding(padding: const EdgeInsets.only(left: 30, right: 8.0, top: 8.0, bottom: 8.0),
child: CircleAvatar(
backgroundImage: NetworkImage(imageUrl)),
),
],
),
]
另一个解决方案:在AppBar-Title中使用变量name
:
title: Text("Welcome Back, $name", style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20),),
actions: <Widget>[
Row(
children: <Widget>[
/// Play with the parameter `left: ...`
Padding(padding: const EdgeInsets.only(left: 30, right: 8.0, top: 8.0, bottom: 8.0),
child: CircleAvatar(
backgroundImage: NetworkImage(imageUrl)),
),
],
),
]
结果: