[英]Flutter : How to align TextField with other widgets in row
I have a row with a Text () and a TextField () But they don't seem to align I'm an Android Developer and my past experience seems to have no effect.我有一排 Text () 和一个 TextField () 但它们似乎不对齐我是 Android 开发人员,我过去的经验似乎没有效果。 Do you have any suggestions for Android developers in terms of alignment skills?
在alignment技能方面,您对Android开发者有什么建议吗?
SizedBox(
height:44,
child:
Row(crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("+60",
textAlign: TextAlign.start,
style: TextStyle(fontSize: 15,
color: Colors.white
),),
Container(margin:EdgeInsets.fromLTRB(15,0,15,0)
,width: 1,height: 12,color: Color(0x33FFFFFF),),
Expanded(//TextField
child: TextField(
textAlign: TextAlign.start,
keyboardType: TextInputType.number,
cursorColor: Color(0x66FFFFFF),
style: TextStyle(
color: Colors.white,
fontSize:15
),
inputFormatters: [
WhitelistingTextInputFormatter
.digitsOnly,
LengthLimitingTextInputFormatter(10)
],
decoration: InputDecoration(
hintText: 'Phone number',
hintStyle: TextStyle(
color: Color(0x66FFFFFF),
fontSize: 15
),
border: InputBorder.none
),
),
)
,
],)
)
the SizedBox
height
property is controlling the Row
constraint thus it's not allowing it to align it's childern freely, just remove the SizedBox
widget and everything will work fine. SizedBox
height
属性控制Row
约束,因此它不允许它自由对齐它的子节点,只需删除SizedBox
小部件,一切都会正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.