我想要嵌套列表视图,其中水平列表视图中会有垂直列表视图,并且将用 SingleChildScrollView 包裹,因为我想一起滚动所有垂直列表。
这就是我所做的
Expanded(
child: Stack(
children: [
Container(
height: double.infinity,
width: double.infinity,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Theme.of(context).primaryColorDark,
Theme.of(context).primaryColorLight,
],
)),
),
SingleChildScrollView(
scrollDirection: Axis.vertical,
physics: const BouncingScrollPhysics(),
child: SizedBox(
height: 200.w,
child: ListView.builder(
scrollDirection: Axis.horizontal,
physics: const BouncingScrollPhysics(),
itemCount: 5,
itemBuilder: (context, index) {
return SizedBox(
height: double.infinity,
width: 24.w,
child: Column(
children: [
Container(
width: double.infinity,
padding: EdgeInsets.fromLTRB(
0.w, 3.w, 0, 3.w),
color: Colors.white,
child:
Center(child: Text("Header"))),
ListView.builder(
physics:
const NeverScrollableScrollPhysics(),
itemCount: 20,
shrinkWrap: true,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {},
child: Padding(
padding: EdgeInsets.fromLTRB(
0.w, 2.w, 0.w, 2.w),
child: Center(
child: Text(
"8:44",
style: TextStyle(
color: Colors.white,
fontSize: 14.sp)),
),
),
);
},
)
],
),
);
},
),
))
],
))
预期输出:
但是,如果我不将垂直列表视图放在 SizedBox 中并且不给出固定高度,那么它会导致问题。
我想在列表视图中垂直扩展或类似 wrap_content 的内容,以便它自己占用所需的空间。
那我该怎么办?有人可以帮忙吗?
提前致谢。
© 版权声明
本站下载的源码均来自公开网络收集转发二次开发而来,
若侵犯了您的合法权益,请来信通知我们1413333033@qq.com,
我们会及时删除,给您带来的不便,我们深表歉意。
下载用户仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,访问及下载者下载默认同意本站声明的免责申明,请合理使用切勿商用。
THE END
暂无评论内容