如何去除滚动发光? [英] How to remove scroll glow?
问题描述
默认情况下,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屋!