如何去除滚动发光? [英] How to remove scroll glow?

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

问题描述

默认情况下,flutter 会在 ListView/GridView/... 上添加发光效果,以便在安卓手机上滚动

By default, flutter adds a glowing effect on ListView/GridView/... to overscrolls on android phones

我想完全或在一个特定的滚动条上删除此效果.我知道我可以更改 ScrollPhysics 以在 Bounce/Clamp 之间切换.但这实际上并没有消除发光效果.

I would like to remove this effect entirely or on one specific scrollable. I know that I can change ScrollPhysics to change between Bounce/Clamp. But this doesn't actually remove the glow effect.

我能做什么?

推荐答案

发光效果来自 GlowingOverscrollIndicator滚动行为

The glow effect comes from GlowingOverscrollIndicator added by ScrollBehavior

要消除此效果,您需要指定自定义ScrollBehavior.为此,只需将应用程序的任何给定部分包装到 ScrollConfiguration 与所需的 ScrollBehavior.

To remove this effect, you need to specify a custom ScrollBehavior. For that, simply wrap any given part of your application into a ScrollConfiguration with the desired ScrollBehavior.

以下 ScrollBehavior 将完全消除发光效果:

The following ScrollBehavior will remove the glow effect entirely :

class MyBehavior extends ScrollBehavior {
  @override
  Widget buildViewportChrome(
      BuildContext context, Widget child, AxisDirection axisDirection) {
    return child;
  }
}

要消除整个应用程序的发光效果,您可以将其添加到 MaterialApp 下:

To remove the glow on the whole application, you can add it right under MaterialApp :

MaterialApp(
  builder: (context, child) {
    return ScrollConfiguration(
      behavior: MyBehavior(),
      child: child,
    );
  },
  home: new MyHomePage(),
);

要在特定的 ListView 上删除它,只需将所需的 ListView 包装起来:

To remove it on a specific ListView, instead wrap only the desired ListView :

ScrollConfiguration(
  behavior: MyBehavior(),
  child: ListView(
    ...
  ),
)

<小时>

如果您想改变效果,这也是有效的.就像在到达滚动视图的边界时添加淡入淡出一样.


This is also valid if you want to change the effect. Like adding a fade when reaching borders of the scroll view.

这篇关于如何去除滚动发光?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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