如标题中所述;当我在文本字段的长度上添加太多文本时,我的文本“消失”了,为什么会发生这种情况?
这是代码
Container(
height: mediaSize.height * .075,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(12.5)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.black54.withOpacity(0.45),
spreadRadius: 1,
blurRadius: 4,
offset: Offset(3.5, 4))
]),
child: TextFormField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: myLightOrangeColor),
borderRadius: BorderRadius.all(
Radius.circular(12.5))),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: myLightOrangeColor, width: 6),
borderRadius: BorderRadius.all(
Radius.circular(12.5))),
labelStyle: TextStyle(color: Colors.black, fontSize: 15, fontWeight: FontWeight.bold),
filled: true,
fillColor: Colors.white),
keyboardType: TextInputType.text,
style: TextStyle(color: Colors.black, fontSize: 15, fontWeight: FontWeight.bold),
),
),
答案 0 :(得分:2)
要使TextField的文本正常显示,需要其正常的高度,在图像下方的图像中,不给Container赋予高度:
但是如果您给它的高度小于需要显示文本的高度(在此示例中,设备的高度乘以0.075):
要减小TextField的高度,可以更改属性contentPadding
或将isDense
设置为true
:
TextFormField(
decoration: InputDecoration(
isDense: true,
//contentPadding: EdgeInsets.all(0), //or any padding you want
),
keyboardType: TextInputType.text,
style: TextStyle(
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
),
),