Flutter应用程序,Android:我正在尝试减少TextFormField的底部填充(我需要在相当小的屏幕上放置一些字段(移动android数据收集器)。)
我尝试使用contentPadding InputDecoration,但是它没有按我预期的那样工作。
这里的底部填充为10:
decoration: InputDecoration(
...
contentPadding: new EdgeInsets.fromLTRB(10, 10, 10, 10):
这里的底部填充为4:
decoration: InputDecoration(
...
contentPadding: new EdgeInsets.fromLTRB(10, 10, 10, 4):
如您所见,TextFormFields内的文本底部填充没有太大变化,仍然浪费了太多空间。同样,由于某种原因,顶部填充也发生了变化,从而使内容文本与标签文本过于接近。我不想更改顶部填充。
如何减少底部填充(在文本和边框之间)?
编辑11/18/2019,每个请求的完整TextFormField:
TextFormField(
initialValue: widget.initialValue,
textInputAction: TextInputAction.next,
enabled: widget.enabled,
minLines: widget.lines,
maxLines: widget.lines,
autofocus: widget.autoFocus,
focusNode: widget.focusNode,
keyboardType: widget.keyboardType,
maxLength: widget.maxLength,
maxLengthEnforced: true,
readOnly: widget.readonly,
inputFormatters: widget.inputFormatters,
controller: widget.controller,
style: TextStyle(
fontSize: 17,
color: widget.textColor != null ? widget.textColor : null,
),
onFieldSubmitted: widget.onFieldSubmitted,
onEditingComplete: widget.onEditingComplete,
decoration: InputDecoration(
labelText: widget.labelText,
labelStyle: TextStyle(color: widget.enabled ? Colors.grey[600] : Colors.grey[500]),
hintText: widget.hintText != null ? widget.hintText : widget.labelText,
counterText: '',
errorText: widget.errorText,
filled: true,
fillColor: widget.fillColor != null ? widget.fillColor : widget.enabled ? Colors.white : Colors.grey[100],
contentPadding: new EdgeInsets.fromLTRB(10, 10, 10, 10),
border: OutlineInputBorder(),
),
),
答案 0 :(得分:0)
尝试在inputDecoration中添加小于默认值的 isDense:true 。这对我有帮助
decoration: InputDecoration(
isDense: true,
// contentPadding: new EdgeInsets.fromLTRB(0, 0, 0, 0),
contentPadding: EdgeInsets.only(top: 4,bottom: 4,left: 6,right: 6),
hintText: "Enter name",
hintStyle: TextStyle(color: Colors.grey),
border: InputBorder.none,
),