Android 如何在颤振中将TextFormField的文本与中心垂直对齐?
我对Flutter开发还不熟悉&尝试了一些解决方法,但没有任何真正的帮助。我希望我的文本在flatter的Android 如何在颤振中将TextFormField的文本与中心垂直对齐?,android,flutter,Android,Flutter,我对Flutter开发还不熟悉&尝试了一些解决方法,但没有任何真正的帮助。我希望我的文本在flatter的TextFormField中垂直居中 textAlign:textAlign.start将我的文本向左移动,但我希望它们也垂直居中。 textAlign:textAlign.center使我的文本居中,但我希望它们也从左开始 这就是我得到的, 这就是我想要的, 我的代码片段: @override Widget build(BuildContext context) { return ne
TextFormField
中垂直居中
textAlign:textAlign.start
将我的文本向左移动,但我希望它们也垂直居中。
textAlign:textAlign.center
使我的文本居中,但我希望它们也从左开始
这就是我得到的,
这就是我想要的,
我的代码片段:
@override
Widget build(BuildContext context) {
return new Form(
key: _formKey,
child: new SingleChildScrollView(
child: new Theme(
data: new ThemeData(
primaryColor: const Color(0xFF102739),
accentColor: const Color(0xFF102739),
hintColor: const Color(0xFF102739)),
child: new Column(
children: <Widget>[
new TextFormField(
textAlign: TextAlign.center,
maxLines: 1,
autofocus: true,
keyboardType: TextInputType.emailAddress,
style: new TextStyle(
color: const Color(0xFF0f2638),
fontFamily: 'ProximaNova',
fontStyle: FontStyle.italic,
fontSize: 16.0),
decoration: new InputDecoration(
contentPadding: const EdgeInsets.only(
top: 8.0, bottom: 8.0, left: 10.0, right: 10.0),
hintText: "YOUR E-MAIL",
hintStyle: new TextStyle(
color: const Color(0x703D444E),
fontFamily: 'ProximaNova',
fontStyle: FontStyle.italic,
fontSize: 16.0),
border: new UnderlineInputBorder(
borderSide: new BorderSide(
color: const Color(0xFF0f2638), width: 0.2))),
validator: _validateEmail,
),
],
),
)));
}
@覆盖
小部件构建(构建上下文){
返回新表格(
键:_formKey,
子:新的SingleChildScrollView(
儿童:新主题(
数据:新主题数据(
原色:常量颜色(0xFF102739),
accentColor:const Color(0xFF102739),
hintColor:const Color(0xFF102739)),
子:新列(
儿童:[
新TextFormField(
textAlign:textAlign.center,
maxLines:1,
自动对焦:对,
键盘类型:TextInputType.emailAddress,
样式:新文本样式(
颜色:常量颜色(0xFF0f2638),
fontFamily:“ProximaNova”,
fontStyle:fontStyle.italic,
字体大小:16.0),
装饰:新的输入装饰(
contentPadding:const EdgeInsets.only(
顶部:8.0,底部:8.0,左侧:10.0,右侧:10.0),
hintText:“您的电子邮件”,
hintStyle:新的文本样式(
颜色:常量颜色(0x703D444E),
fontFamily:“ProximaNova”,
fontStyle:fontStyle.italic,
字体大小:16.0),
边框:新的下划线输入边框(
borderSide:新的borderSide(
颜色:常量颜色(0xFF0f2638),宽度:0.2),
验证程序:_validateEmail,
),
],
),
)));
}
没有垂直对齐选项。您只需为定位设置contentPadding:
TextFormField(
decoration: InputDecoration(
contentPadding: EdgeInsets.zero
)
我使用“对齐:对齐.center,”对带有“输入装饰.collapsed”和“.copyWith(isDense:true)”的容器执行此操作的方式:
使用以下属性:
TextFormField(
textAlignVertical: TextAlignVertical.center,
//Remaining code.
),
您的意思是在文本输入中,文本应该垂直居中?是的,提示和输入文本都应该垂直居中@dhuma1981您是如何解决的?尚未收到任何解决方案,请回答您是否可以解决它。只需使用填充将
TextFormField
包装起来,并将EdgeInsets.all(/*value*/)作为填充。。最好把所有的东西都装在一个容器里。并给容器和TextFormField内部添加填充物进行形状装饰。然后删除所有textAlign属性通常我不知道如何右对齐标签文本,但这个解决方案给了我一个想法。这对我很有用,谢谢你broyes,它可以折叠属性
TextFormField(
textAlignVertical: TextAlignVertical.center,
//Remaining code.
),