问题描述
假设我有一个大小为{100x100}的PageView,其中有4个孩子,因此,在我滚动到第二个孩子之前,只有一个孩子可见.我想要的是使所有4个孩子都在屏幕上可见.有没有办法做到这一点?
Let say I have a PageView sized {100x100} with 4 children, so there will be only 1 child visible at the time, until I scroll to the second child. What I want is to make all 4 children are visible on the screen. Is there a way to achieve this?
推荐答案
回答我自己的问题有点可笑,但无论如何我还是在做,以为有人可能需要这个.
Answering my own question is kind of funny, but I'm doing it anyway, thought that someone might need this.
感谢这篇文章:非viewportFraction<的PageView的中心对齐1.0
现在,我可以将PageScrollPhysics()
应用于ListView
以实现此效果.像这样:
Now I can apply PageScrollPhysics()
to a ListView
to achieve this effect.Like this:
var _listView = ListView(physics: PageScrollPhysics());
正如@Ferdi所说,PageView
不是为此设计的.因此,只需使用ListView
或SingleChildScrollView()
并应用PageScrollPhysics()
,它就能解决问题!
As @Ferdi said, PageView
is not designed for this. So just go with ListView
or SingleChildScrollView()
and apply the PageScrollPhysics()
, it will do the trick!
这篇关于有没有一种方法可以禁用PageView裁剪效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!