gpt4 book ai didi

flutter - 使 ListView 生成器表现得像 Android wrap_content

转载 作者:IT王子 更新时间:2023-10-29 07:07:12 25 4
gpt4 key购买 nike

我的专栏结构是这样的:

body: new Column(
children: <Widget>[
new TabPanel(), // row with all child text
new UrlButtonPanel(), // row with button
new Ad(), //rectangle container
new LatestNewsController(), //container with swith button
Expanded(child: new LatestNewsList()), // listview

],
)

我想让整个页面都可以滚动,包括 listView。现在只有 Listview 部分是可滚动的。

如何使整个页面可滚动?

用 ListView 替换 Column 使布局空白。

最佳答案

试试这些改变。它应该在 Scrollable ListView 中为您提供一个 Scrollable List。编辑:在 Widget 构建方法中添加:

// Get the screen Height
double screenHeight = MediaQuery.of(context).size.height;
// Get 67% of screen Height
double containerHeight = screenHeight * 0.67;
// Get the screen Width
double screenWidth = MediaQuery.of(context).size.width;

这将为您提供屏幕高度和宽度,然后在 Container 中使用 containerHeight。在这种情况下,我使用了屏幕高度的 67%。

body: new ListView(
children: <Widget>[
new TabPanel(), // row with all child text
new UrlButtonPanel(), // row with button
new Ad(), //rectangle container
new LatestNewsController(), //container with swith button
new Container(height: containerHeight, child: yourList()),
],
),

关于flutter - 使 ListView 生成器表现得像 Android wrap_content,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52134721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com