禁用ListView滚动 [英] Disable ListView Scroll

查看:97
本文介绍了禁用ListView滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果页面没有溢出屏幕尺寸,是否可以禁用ListView Scroll?

我总是使用ListView来避免屏幕溢出,但是当页面的内容小于屏幕时,我可以看到结束滚动动画,在这种情况下如何禁用滚动,并且如果屏幕大小可以滚动小吗?

我认为最好的方法是使用 SingleChildScrollView(子:列(mainAxisSize:MainAxisSize.min,子代:< Widget> [/**/],),)

或者如果出于某种原因需要使用 ListView ,则可以将 shrinkWrap NeverScrollableScrollPhysics 一起使用:

  SingleChildScrollView(子级:ListView(rinkWrap:是的,物理:NeverScrollableScrollPhysics(),子代:< Widget> [/**/],),) 

Is possible to disable ListView Scroll if page don't overflow the screen size?

I always use ListView to avoid overflow the screen, but when the content of the page is smaller than screen I can see the end scroll animation, how can i disable the scroll in this cases, and able to scroll if the screen size is small??

解决方案

I think the best way to do this is to use a SingleChildScrollView:

This widget is useful when you have a single box that will normally be entirely visible, for example a clock face in a time picker, but you need to make sure it can be scrolled if the container gets too small in one axis (the scroll direction).

And instead of using a ListView just use a Column and place it inside of the SingleChildScrollView:

    SingleChildScrollView(
        child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[/**/],
        ),
    )

Or if you need to use ListView for some reason, you can use shrinkWrap with NeverScrollableScrollPhysics:

    SingleChildScrollView(
        child: ListView(
            shrinkWrap: true,
            physics: NeverScrollableScrollPhysics(),
            children: <Widget>[/**/],
        ),
    )

这篇关于禁用ListView滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆