簡體   English   中英

Flutter:如何將 TextField 與行中的其他小部件對齊

[英]Flutter : How to align TextField with other widgets in row

我有一排 Text () 和一個 TextField () 但它們似乎不對齊我是 Android 開發人員,我過去的經驗似乎沒有效果。 在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
                                  ),
                                ),
                              )
                                ,
                          ],)
                        )

SizedBox height屬性控制Row約束,因此它不允許它自由對齊它的子節點,只需刪除SizedBox小部件,一切都會正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM