如何在flutter的文本字段中使用标签文字?[关闭]

问题描述 投票:0回答:1

1 我的标签文字有一些带边框的填充物,如何去掉这些空间? 2 如何在文本框内写标签文字?

enter image description here

flutter flutter-layout flutter-dependencies flutter-animation flutter-web
1个回答
0
投票

1) 对于textformfield中的padding,你应该编辑装饰中的contentPadding,例如,在 "装饰 "中的 "padding"。

TextField(
   maxLines: 8,
   decoration: InputDecoration(
      contentPadding: EdgeInsets.fromLTRB(0,0,0,0), <--
      labelText: 'Description',
      labelStyle: txtHintStyle,
   )
 )

然后放上你想要的任何东西,比如把它覆盖为0。

2) 如果你已经定义了标签文本,请删除提示文本,当你选择textformfield时,标签文本会自动覆盖在标签上。

3) TextFormField提供了textAlign参数,例如:。

TextFormField(
  textAlign: TextAlign.center,    <--
  controller: _username,
),
© www.soinside.com 2019 - 2024. All rights reserved.