Flutter 将labelText添加到容器的框装饰上(作为TextField)
TextField有一个很好的方法将文本标签放置在它的框装饰上 与: 对于集装箱的其他盒子装饰,有没有办法达到同样的效果?例如,我想指定标签XP:Flutter 将labelText添加到容器的框装饰上(作为TextField),flutter,Flutter,TextField有一个很好的方法将文本标签放置在它的框装饰上 与: 对于集装箱的其他盒子装饰,有没有办法达到同样的效果?例如,我想指定标签XP: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(5)), border: Border.all(color: color, width: 2.0)
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
border: Border.all(color: color, width: 2.0),
labelText: Text("XP"), // No such attribute
),
child: child,
),
。。。但是,Flatter不提供用于BoxEdition的labelText,而只提供用于InputEdition的labelText。恐怕您必须使用Stack来做一些不同的事情
Stack(
children: <Widget>[
Container(
height: 80,
),
Positioned(
bottom: 0,
child: Container(
width: 250,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
border: Border.all(color: Colors.black, width: 2.0),
),
),
),
Positioned(
left: 10,
bottom: 40,
child: Container(color: Colors.white, child: Text('XP')),
)
],
)
恐怕你得用Stack做得有点不同
Stack(
children: <Widget>[
Container(
height: 80,
),
Positioned(
bottom: 0,
child: Container(
width: 250,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
border: Border.all(color: Colors.black, width: 2.0),
),
),
),
Positioned(
left: 10,
bottom: 40,
child: Container(color: Colors.white, child: Text('XP')),
)
],
)
您可以使用InputDecorator 容器 子:输入装饰器 装饰:输入装饰 labelText:'XP', 边框:大纲输入边框 borderRadius:borderRadius.circular10.0, , , 孩子:文本“内容在这里”, ,
您可以使用InputDecorator 容器 子:输入装饰器 装饰:输入装饰 labelText:'XP', 边框:大纲输入边框 borderRadius:borderRadius.circular10.0, , , 孩子:文本“内容在这里”, ,
您还可以使用position执行以下操作
Stack(
children: [
Container(
height: 88,
width: 88,
child: ImagePickerWidget(
diameter: 180,
initialImage: "${snapshot.data['imagePath']}",
shape: ImagePickerWidgetShape
.circle, // isEditable: true,
),
),
Positioned(
left: 5,
bottom: 28,
child: Container(
color: Colors.transparent,
child: Text(
'Double Tap\nto Call',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.normal),
)),
)
],
)
您还可以使用position执行以下操作
Stack(
children: [
Container(
height: 88,
width: 88,
child: ImagePickerWidget(
diameter: 180,
initialImage: "${snapshot.data['imagePath']}",
shape: ImagePickerWidgetShape
.circle, // isEditable: true,
),
),
Positioned(
left: 5,
bottom: 28,
child: Container(
color: Colors.transparent,
child: Text(
'Double Tap\nto Call',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.normal),
)),
)
],
)
如何使高度自动?如何使高度自动?文本与边框重叠。这对我很有用。谢谢。文字与边框重叠。对我很有用。谢谢
Stack(
children: [
Container(
height: 88,
width: 88,
child: ImagePickerWidget(
diameter: 180,
initialImage: "${snapshot.data['imagePath']}",
shape: ImagePickerWidgetShape
.circle, // isEditable: true,
),
),
Positioned(
left: 5,
bottom: 28,
child: Container(
color: Colors.transparent,
child: Text(
'Double Tap\nto Call',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.normal),
)),
)
],
)