如何使listview像图像一样水平滚动
另一种解释我想在黑色容器内构建这样的滚动列表
![在此处输入图像说明] [1]
码
body: Center (
child: Container(
height: 400.0,
width: 300.0,
color: Colors.white,
child: Container(
margin: EdgeInsets.symmetric(vertical: 90.0),
child: ListView(
// This next line does the trick.
scrollDirection: Axis.horizontal,
children: <Widget>[
Container(
width: 160.0,
color: Colors.red,
),
Container(
width: 160.0,
color: Colors.blue,
),
Container(
width: 160.0,
color: Colors.green,
),
Container(
width: 160.0,
color: Colors.yellow,
),
Container(
width: 160.0,
color: Colors.orange,
),
],
)
),
),
)
用Center
替换你的Align
小部件,并根据你的需要设置alignment
:
body: Align(
alignment: Alignment.bottomCenter, // or Alignment.topCenter
child: Container(
height: 200.0,
width: 300.0,
color: Colors.white,
child: Container(
child: ListView(
...
你知道列小部件吗?如果没有那么试试,告诉我这是否是你想要的