我是新手,我想在下面的代碼中為影像設定上邊距,我該怎么做?只需在螢屏上設計一個帶有文本和影像的螢屏。
這是我的代碼:
Widget build(BuildContext context) {
SizeConfig().init(context);
return Container(
padding: new EdgeInsets.only(
top: 160,
left: SizeConfig.blockSizeHorizontal * 5,
right: SizeConfig.blockSizeHorizontal * 5),
decoration: BoxDecoration(
image: DecorationImage(
image: new AssetImage("images/bg_splash.png"),
fit: BoxFit.fill)),
child: Column(
children: [
Text(
"App is allowing users to learn & Grow their Brains",
textAlign: TextAlign.center,
style: TextStyle(
decoration: TextDecoration.none,
fontSize: 25.0,
color: Color(0xFFFDEA20),
fontFamily: "Calistoga",
),
),
Image(
image: AssetImage('images/logo.png'),
height: 175,
),
],
));
}
uj5u.com熱心網友回復:
在小部件SizedBox(height: 10.0),上方的列中添加您的要求Image()
return Container(
padding: new EdgeInsets.only(
top: 160,
left: SizeConfig.blockSizeHorizontal * 5,
right: SizeConfig.blockSizeHorizontal * 5),
decoration: BoxDecoration(
image:
DecorationImage(image: new AssetImage("images/bg_splash.png"), fit: BoxFit.fill)),
child: Column(
children: [
Text(
"App is allowing users to learn & Grow their Brains",
textAlign: TextAlign.center,
style: TextStyle(
decoration: TextDecoration.none,
fontSize: 25.0,
color: Color(0xFFFDEA20),
fontFamily: "Calistoga",
),
),
SizedBox(height: 10.0),
Image(
image: AssetImage('images/logo.png'),
height: 175,
),
],
));
uj5u.com熱心網友回復:
用填充包裹你的影像小部件
Padding(
padding: const EdgeInsets.only(top:10),
child: Image(
image: AssetImage('images/logo.png'),
height: 175,
),
),
uj5u.com熱心網友回復:
這里有兩個解決方案
- 用填充包裹你的影像
Padding( padding: EdgeInsets.only( bottom: 12, top: 12, left:10, right:10), child: Image( image: const AssetImage("images/logo.png"), width:125, ), ),
- 使用 Container 添加邊距屬性包裝您的影像
Container( margin: EdgeInsets.only( left: 10, right: 10, bottom:10, top:10), child: Image( image: const AssetImage("images/logo.png"), width: MediaQuery.of(context).size.width * 0.25, ), ),
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/495065.html
