更改Flutter TextField比例 [英] Changing Flutter TextField proportions
问题描述
我开始将代码从使用标准的Android库过渡到Flutter,以便也可以快速部署到iOS设备上,但是我只关心TextField的比例;即Flutter的TextField的比例不同于Android的EditText.
I'm starting to transition my code from using standard Android libraries, into Flutter, so I can rapidly deploy onto iOS devices as well, but I just have a concern about the proportions of the TextField; namely that the proportions of Flutter's TextField differs from the EditText of Android.
为进行比较,这是Android的EditText:
To compare, here's Android's EditText:
这是Flutter的TextField:
and here's Flutter's TextField:
有没有办法使Flutter TextField看起来更像Android EditText?下划线和占位符文本之间的空间使我很烦,并且输入文本的大小比我预期的要小.如果RaisedButton看起来与普通的Android Button完全一样,为什么TextField不能这样做?
Is there a way to make the Flutter TextField look more like the Android EditText? The space between the underline and the placeholder text annoys me, and the size of the input text is smaller than I expected. If the RaisedButton looks exactly like the normal Android Button, why can't TextField do the same?
推荐答案
在 InputDecoration
中设置 isDense:true
.然后根据需要在 InputDecoration
中调整 contentPadding
Set the isDense: true
in InputDecoration
. Then adjust contentPadding
in InputDecoration
as you want
TextField(
decoration: InputDecoration(
hintText: "Username",
isDense: true,
contentPadding: EdgeInsets.symmetric( //You can also use EdgeInsets.only
horizontal: 0.0, //Change this
vertical: 0.0, //Change this
),
),
)
请参见演示此处
这篇关于更改Flutter TextField比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!