简体   繁体   English

如何制作单个垂直可滚动列表,其中每个项目都是水平可滚动列表?

[英]How to make a single vertical scrollable list where each item is a horizontal scrollable list?

I am trying to create a single vertical scrollable list where each item is a horizontal scrollable list.我正在尝试创建一个垂直可滚动列表,其中每个项目都是一个水平可滚动列表。

  • The single vertical list should grow its height as big as possible.单个垂直列表的高度应尽可能大。
  • Each horizontal list should have a fixed height.每个水平列表应该有一个固定的高度。

How can I do something like this without external packages?如果没有外部包,我怎么能做这样的事情呢?

You could create your horizontal list by putting a listview (or its variant like listview.builder or listview.separated) in a sized box with a fixed height and setting the scroll direction as Axis.horizontal.您可以通过将列表视图(或其变体,如 listview.builder 或 listview.separated)放在具有固定高度的大小框中并将滚动方向设置为 Axis.horizontal 来创建水平列表。

You could have multiple horizontal lists like above in a column and wrap your column with a single child scroll view.你可以在一列中有多个像上面这样的水平列表,并用一个子滚动视图包裹你的列。

    body: SingleChildScrollView(child: Column(children: [
          SizedBox(
              height: 100,
              child: ListView(scrollDirection: Axis.horizontal, children: [
                MyWidget1(),
                MyWidget2(),
                MyWidget3(),
              ])),
          SizedBox(
              height: 100,
              child: ListView(scrollDirection: Axis.horizontal, children: [
                MyWidget1(),
                MyWidget2(),
                MyWidget3(),
              ])),
          SizedBox(
              height: 100,
              child: ListView(scrollDirection: Axis.horizontal, children: [
                MyWidget1(),
                MyWidget2(),
                MyWidget3(),
              ])),
        ])),
      ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM