如何在底部放置一个 child(带有文本的容器)并使其宽度与他的 sybilings 相同并将文本保持在中心
how to position a child (the container with the text) in the bottom and make it's width the same as his sybilings and keep the text in the center
我正在尝试将第二个容器(带有文本的那个)放在底部,我想使黑色不透明度与第一个容器(图像)的宽度相同,并将文本保留在中心
child: Stack(
children: <Widget>
[
Container
(
padding: EdgeInsets.fromLTRB(0,0,0,0),
child: new Image
(
image: new AssetImage('images/99.jpg'),
fit: BoxFit.cover
)
),
new Positioned(
bottom: 0,
child: Container
(
padding: EdgeInsets.all(7.0),
color: Colors.black.withOpacity(0.3),
child: Text("The text", style: TextStyle(color: Colors.white, fontSize: 25.0), textAlign: TextAlign.center,),
),
),
enter image description here
我想,你正在搜索它--
这是这个容器的代码 --
child: Stack(
children: <Widget>[
Container(
color: Colors.green,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 2,
),
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 2,
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
color: Colors.black12,
height: 50.0,
width: MediaQuery.of(context).size.width,
child: Center(child: Text("abirahsan122@gmail.com")),
)),
)
],
),
我正在尝试将第二个容器(带有文本的那个)放在底部,我想使黑色不透明度与第一个容器(图像)的宽度相同,并将文本保留在中心
child: Stack(
children: <Widget>
[
Container
(
padding: EdgeInsets.fromLTRB(0,0,0,0),
child: new Image
(
image: new AssetImage('images/99.jpg'),
fit: BoxFit.cover
)
),
new Positioned(
bottom: 0,
child: Container
(
padding: EdgeInsets.all(7.0),
color: Colors.black.withOpacity(0.3),
child: Text("The text", style: TextStyle(color: Colors.white, fontSize: 25.0), textAlign: TextAlign.center,),
),
),
enter image description here
我想,你正在搜索它--
这是这个容器的代码 --
child: Stack(
children: <Widget>[
Container(
color: Colors.green,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 2,
),
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 2,
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
color: Colors.black12,
height: 50.0,
width: MediaQuery.of(context).size.width,
child: Center(child: Text("abirahsan122@gmail.com")),
)),
)
],
),