如何在 flutter 中使用文本字段中的标签文本?
how to work with label text in text field in flutter?
1 我的标签文本有一些带边框的填充,如何删除它 space?
2 如何在文本字段的边框内写标签文本?
3 如何调整flutter中标签文字的对齐方式?
1) textformfield 中的padding 你应该编辑Decoration 中的contentPadding,例如:
TextField(
maxLines: 8,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(0,0,0,0), <--
labelText: 'Description',
labelStyle: txtHintStyle,
)
)
然后把你想要的任何东西都写成 0。
2) 如果您已经定义了标签文本,请删除提示文本,当您 select 文本表单字段时,标签文本将自动覆盖标签。
3) TextFormField 提供textAlign 参数,eg:
TextFormField(
textAlign: TextAlign.center, <--
controller: _username,
),
1 我的标签文本有一些带边框的填充,如何删除它 space? 2 如何在文本字段的边框内写标签文本? 3 如何调整flutter中标签文字的对齐方式?
1) textformfield 中的padding 你应该编辑Decoration 中的contentPadding,例如:
TextField(
maxLines: 8,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(0,0,0,0), <--
labelText: 'Description',
labelStyle: txtHintStyle,
)
)
然后把你想要的任何东西都写成 0。
2) 如果您已经定义了标签文本,请删除提示文本,当您 select 文本表单字段时,标签文本将自动覆盖标签。
3) TextFormField 提供textAlign 参数,eg:
TextFormField(
textAlign: TextAlign.center, <--
controller: _username,
),