相信大家对于RecyclerView 都已经不再陌生,我们都知道RecyclerView等可滑动控件默认的是会有滚动条以及滑动到边缘时的阴影(光晕)效果的,那么怎样去掉这两个默认属性呢,在这里简单的记录一下

1、通过xml文件设置

android:scrollbars=""有三个属性

  1. none:去掉滚动条
  2. horizontal:设置水平的滚动条
  3. vertical:设置垂直的滚动条

2、通过java代码设置

RecyclerView.setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled);
RecyclerView.setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled);
设置为true时有相应的滚动条,为false时无相应的滚动条
滚动到边缘的光晕效果

1、通过xml文件设置

android:overScrollMode=""同样有三个属性
never:去掉光晕效果
always:设置总是出现光晕效果
ifContentScrolls:设置此模式,如果recycleview里面的内容可以滑动,那么滑到边界后继续滑动会出现弧形光晕;如果recycleview里面的内容不可以滑动,那么滑到边界后继续滑动不会出现弧形光晕

2、通过java代码设置

a.RecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER)同xml设置为never
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"/>