How to align a TextField and a Text on the same level

跟風遠走 提交于 2021-02-10 08:03:09

问题


I'm trying to align horizontal bottom 1 Text and 1 TextField value using Row, but TextField value always higher than the left Text.

is it possible to align horizontal bottom Text and TextField value even when the font-size more bigger ?

Here are my code and screenshot:

body: Column(  
            children: <Widget>[
                    Row(
                    children: <Widget>[
                        Text('Number 1 : '),
                        Expanded(
                            child:
                            TextField(
                                textAlign: TextAlign.start,
                                textAlignVertical: TextAlignVertical.bottom,
                                textCapitalization: TextCapitalization.sentences,
                                maxLength: 10,
                            ),
                        ),  

                    ]),

                ],
            )


回答1:


You should set textBaseline and crossAxisAlignment for Row.

Row(
    crossAxisAlignment: CrossAxisAlignment.baseline, // <--
    textBaseline: TextBaseline.alphabetic, // <--
    children: <Widget>[
        Text('Number 1 : '),
    ...

It will look like this



来源:https://stackoverflow.com/questions/60969898/how-to-align-a-textfield-and-a-text-on-the-same-level

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!