如何将文本字段的值居中(颤动)

问题描述 投票:-1回答:2

如何将文本字段的值居中(颤动)。这样,无论单词有多大,它始终位于中心?还有如何删除下划线栏?

new Container(

        alignment: Alignment(0.00 , 0.50),

       child: new TextField(                                 
    style: new TextStyle(
      fontSize: 40.0,
      height: 2.0,
      color: Colors.white                  
    )
  )
flutter textfield center
2个回答
0
投票

@@ Anton,您是否尝试过textAlign: TextAlign.center将下面的文字和装饰居中以删除下划线?

TextField(
  textAlign: TextAlign.center,
  style: new TextStyle(
    fontSize: 22.0, fontWeight: FontWeight.bold),
  decoration: new InputDecoration.collapsed(
    hintText: "Name",
  )
)

截屏:

screenshot


0
投票

您可以使用decoration和textAlign属性,请尝试下面的代码:

TextField( .... decoration: InputDecoration( enabledBorder: const OutlineInputBorder( borderSide: const BorderSide(color: Colors.white), ), focusedBorder: const OutlineInputBorder( borderSide: const BorderSide(color: Colors.white), ), ), textAlign: TextAlign.center, );

© www.soinside.com 2019 - 2024. All rights reserved.