如何在容器内构建listview滚动?

问题描述 投票:1回答:2

如何使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,
              ),
            ],
          )
        ),    
      ),
    )
dart flutter flutter-layout
2个回答
1
投票

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(     
                            ...

1
投票

你知道列小部件吗?如果没有那么试试,告诉我这是否是你想要的

© www.soinside.com 2019 - 2024. All rights reserved.