Android取消RecyclerView、ListView、ScrollView、HorizontalScrollView滑动到边缘闪现灰白色水波纹动画

红太狼 2023-10-17 21:15 211阅读 0赞

Android取消RecyclerView、ListView、ScrollView、HorizontalScrollView滑动到边缘闪现灰白色水波纹动画

标准的Android RecyclerView、ListView、ScrollView、HorizontalScrollView滑动到边缘,会闪现灰白色水波纹动画,以这样大的动画效果提示用户已经滑动到边缘,没法再滑动了。对于这种增强体验是一个很好的设计效果,但是有时候可能不需要这样的效果,取消的方法是在配置RecyclerView、ListView、ScrollView、HorizontalScrollView的xml布局里面,设置:

  1. android:overScrollMode="never"

即可取消。

如果要在上层Java代码处理,也是可以,比如在Android官方的RecyclerView实现代码中:

  1. /**
  2. * Set the over-scroll mode for this view. Valid over-scroll modes are
  3. * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
  4. * (allow over-scrolling only if the view content is larger than the container),
  5. * or {@link #OVER_SCROLL_NEVER}.
  6. *
  7. * Setting the over-scroll mode of a view will have an effect only if the
  8. * view is capable of scrolling.
  9. *
  10. * @param overScrollMode The new over-scroll mode for this view.
  11. */
  12. public void setOverScrollMode(int overScrollMode) {
  13. if (overScrollMode != OVER_SCROLL_ALWAYS &&
  14. overScrollMode != OVER_SCROLL_IF_CONTENT_SCROLLS &&
  15. overScrollMode != OVER_SCROLL_NEVER) {
  16. throw new IllegalArgumentException("Invalid overscroll mode " + overScrollMode);
  17. }
  18. mOverScrollMode = overScrollMode;
  19. }

在这里设置相应的mode一样可以。

发表评论

表情:
评论列表 (有 0 条评论,211人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Shader实例02-动态波纹

    效果预览 拖动滑动条可调节水纹波动频率的快慢。 原理 对当前uv坐标进行线性+三角函数等混合变换,结合动态变化的时间参数,得到一个新的采样坐标,产生图片折射扭曲效