Changing Flutter TextField proportions

吃可爱长大的小学妹 提交于 2021-02-11 13:41:46

问题


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.

To compare, here's Android's EditText:

and here's Flutter's 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?


回答1:


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 
    ),
  ),
)

See demo here



来源:https://stackoverflow.com/questions/59446697/changing-flutter-textfield-proportions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!