How to disable overscroll effect on RecyclerView ONLY when you can't scroll anyway ?

android developer picture android developer · Dec 29, 2016 · Viewed 19.7k times · Source

Background

Sometimes, all items of the recyclerView are already visible to the user.

In this case, it wouldn't matter to the user to see overscroll effect, because it's impossible to actually scroll and see more items.

The problem

I know that in order to disable overscroll effect on RecyclerView, I can just use:

recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);

but I can't find out when to trigger this, when the scrolling isn't possible anyway.

The question

How can I Identify that all items are fully visible and that the user can't really scroll ?

If it helps to assume anything, I always use LinearLayoutManager (vertical and horizontal) for the RecyclerView.

Answer

Ketan Ramani picture Ketan Ramani · Oct 26, 2017
<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:overScrollMode="never"/>

Just add android:overScrollMode="never" in XML