我正在尝试制作一个可滚动的屏幕(如整个屏幕可滚动)。
这是我了解到的:
Column(
children: <Widget>[
Expanded(
child: ListView(
scrollDirection: Axis.horizontal, children: posts2b)),
Expanded(child: ListView(children: posts2a)),
],
);
Run Code Online (Sandbox Code Playgroud)
一切正常,但我希望这些列表视图可以作为一个滚动。因此,如果向下滚动,水平列表视图将“消失”。
那可能吗?
谢谢!
像这样的东西?
SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 200,
child: ListView(
scrollDirection: Axis.horizontal,
children: posts2b,
),
),
Flexible(
child: ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
children: posts2a,
),
),
],
),
)
Run Code Online (Sandbox Code Playgroud)
裹Column带SingleChildScrollView,用于水平列表,并加入了对垂直列表禁用滚动设定的高度physics: NeverScrollableScrollPhysics()...
小智 5
使用 SizedBox() 并给出选项,shrinkWrap: true。
SizedBox(
child: ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
...
),
SizedBox(
child: ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
...
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3759 次 |
| 最近记录: |