[英]How to reduce padding between label text and bottom line in TextformField in Flutter?
With InputDecorationTheme
you can style TextformField
like you want.使用
InputDecorationTheme
,您可以根据需要设置TextformField
的样式。 Also the padding.还有填充物。
Check this out: https://api.flutter.dev/flutter/material/InputDecorationTheme-class.html看看这个: https://api.flutter.dev/flutter/material/InputDecorationTheme-class.html
MaterialApp(
theme: ThemeData(
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(
vertical: 22,
horizontal: 26,
),
labelStyle: TextStyle(
fontSize: 35,
decorationColor: Colors.red,
),
),
)
You should use contentPadding parameter inside TextField's decoration.For example:您应该在 TextField 的装饰中使用contentPadding参数。例如:
TextField(
decoration:InputDecoration(
hintText:"LABEL",
contentPadding: EdgeInsets.only(top:0.0,bottom:0.0)
),
),
You can set content Padding as you like to achieve desired results.您可以根据需要设置内容填充以获得所需的结果。
Another useful prop in InputDecoration
is alignLableWithHint
. alignLableWithHint
InputDecoration
This will lower the starting position to the same level as the text/hint text.这会将起始 position 降低到与文本/提示文本相同的级别。
Normally the label sits higher, even with contentPadding set to 0通常 label 坐得更高,即使 contentPadding 设置为 0
TextField(
decoration:InputDecoration(
hintText:"some label",
alignLabelWithHint: true,
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.