在Flutter中使容器内可滚动文本

编程入门 行业动态 更新时间:2024-10-27 04:34:26
本文介绍了在Flutter中使容器内可滚动文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在视图内创建可滚动文本:

I'm trying to create a scrollable Text inside a view:

// other widgets, SingleChildScrollView( child: Container( height: 200, child: Text( "Long text here which is longer than the container height"))), // other widgets

文本长于其父对象的高度容器,但由于某些原因,尽管将文本包装在 SingleChildScrollView 内,但该文本不可滚动。知道我在做什么错吗?

The text is longer than the height of its parent container, but for some reason the text is not scrollable although it is wrapped inside SingleChildScrollView. Any idea what I'm doing wrong?

推荐答案

尝试添加 scrollDirection (水平):

SingleChildScrollView( scrollDirection: Axis.horizontal, child: Container( height: 200, child: Text( "Long text here which is longer than the container height")))

默认为垂直。

或者,如果您想拥有自己的身高,则必须更改顺序( SingleChildScrollView 内部容器):

Or if you want to have with your height then you have to change the order (SingleChildScrollView inside Container):

Container( height: 200, child: SingleChildScrollView( child: Text( "Long text here which is longer than the container height")))

更多推荐

在Flutter中使容器内可滚动文本

本文发布于:2023-10-08 09:59:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472295.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内可   容器   文本   Flutter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!