如何清除滚动发光? [英] How to remove scroll glow?
问题描述
默认情况下,颤动会在 ListView
/ GridView
/ ...上添加发光效果,从而在Android手机上过度滚动
By default, flutter adds a glowing effect on ListView
/GridView
/... to overscrolls on android phones
我想完全删除此效果或在一个特定的滚动条上删除。
我知道我可以更改 ScrollPhysics
来在弹跳/钳位之间进行切换。但这实际上并不能消除发光效果。
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
由 ScrollBehavior
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屋!