问题
How can I change the grey or white overlay that comes on recyclerview when we try to scroll even when we reached the end(top or bottom) of list. I am not able to find the property name to which I can use to do it.
回答1:
The RecyclerView
take the shadow from the colorPrimary
of your Theme.
You need to create new theme for RecyclerView
then apply this Theme to your RecyclerView
In below example themes colorPrimary
is colorGreen
so it will take green color shadow.
SAMPLE CODE
<android.support.v7.widget.RecyclerView
android:id="@+id/ha_citiesRC"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:requiresFadingEdge="vertical"
android:theme="@style/CustomTheme"
android:nestedScrollingEnabled="false" />
theme
<style name="CustomTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorGreen</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
回答2:
try this in your RecylerView
android:overScrollMode="never"
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:background="#000"
android:scrollbars="vertical" />
回答3:
Change the ColorPrimary for that Activity and Fragment using style Firstly create the style
<style name="RecyclerView" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">"Enter the Color Which you want"</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
After then just set the style to Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.RecyclerView);
setContentView(R.layout.activity_home);
super.onCreate(savedInstanceState);
}
来源:https://stackoverflow.com/questions/48144689/recyclerview-list-end-overlay-color-and-alpha