dart - 在 Flutter 中的容器内制作可滚动文本
问题描述
我正在尝试在视图中创建一个可滚动的文本:
// other widgets,
SingleChildScrollView(
child: Container(
height: 200,
child: Text(
"Long text here which is longer than the container height"))),
// other widgets
文本比其父容器的高度长,但由于某种原因,文本虽然被包裹在SingleChildScrollView
. 知道我做错了什么吗?
解决方案
尝试添加scrollDirection
(水平):
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
height: 200,
child: Text(
"Long text here which is longer than the container height")))
默认为垂直。
或者,如果您想拥有自己的身高,那么您必须更改顺序(SingleChildScrollView
内部Container
):
Container(
height: 200,
child: SingleChildScrollView(
child: Text(
"Long text here which is longer than the container height")))
推荐阅读
- ios - 在移动过度滚动期间停止背景元素移动 (React/CSS)
- node.js - Sequelize:从 Query 返回的实例方法和属性未定义
- ios - 如何以编程方式在集合视图中添加节昆虫?
- java - 从前台服务启动活动不适用于某些应用程序
- python - 从 mariadb 填充组合框可编辑的 human_name 和行编辑电话和电子邮件
- reactjs - 我正在尝试将静态反应应用程序部署到heroku,但出现“cross-env:未找到”之类的错误
- matlab - Matlab绘图,从图例中删除线
- flutter - 如何修复 VSCODE 模拟器?
- javascript - date-fns 如何以 23:59:59 的 00:00:00 格式获取一天的结束
- android - 处理来自外部条码扫描器的数据