去掉RecyclerView等可滑动控件滑动到边缘时的阴影(光晕)效果

RecyclerView等可滑动控件默认的是会有滚动条以及滑动到边缘时的阴影(光晕)效果的,那么怎样去掉这两个默认属性呢,在这里简单的介绍一下

  • 滚动条效果
    1、通过xml文件设置
    android:scrollbars=””有三个属性
    a.none:去掉滚动条
    b.horizontal:设置水平的滚动条
    c.vertical:设置垂直的滚动条
    2、通过java代码设置
    a.RecyclerView.setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled);
    b.RecyclerView.setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled);
    设置为true时有相应的滚动条,为false时无相应的滚动条
  • 滚动到边缘的光晕效果
    1、通过xml文件设置
    android:overScrollMode=””同样有三个属性
    a.none:去掉光晕效果
    b.always:设置总是出现光晕效果
    c.ifContentScrolls:设置此模式,如果recycleview里面的内容可以滑动,那么滑到边界后继续滑动会出现弧形光晕;如果recycleview里面的内容不可以滑动,那么滑到边界后继续滑动不会出现弧形光晕
    2、通过java代码设置
    a.RecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER)同xml设置为none
    b.RecyclerView.setOverScrollMode(View.OVER_SCROLL_ALWAYS)同xml设置为always
    c.RecyclerView.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS)同xml设置为ifContentScrolls
  • 同时去掉滚动条和默认的光晕效果的完整xml代码为:
<android.support.v7.widget.RecyclerView
    android:overScrollMode="never" 
    android:scrollbars="none" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/>
    原文作者:不二程序员
    原文地址: https://blog.csdn.net/Cyx77520/article/details/79016373
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞