问题
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
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?
回答1:
Try to add scrollDirection (horizontal)
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
height: 200,
child: Text(
"Long text here which is longer than the container height"))),
}
Default is vertical
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"))),
来源:https://stackoverflow.com/questions/55515671/make-scrollable-text-inside-container-in-flutter