Android cancels RecyclerView, ListView, ScrollView, HorizontalScrollView sliding to the edge and flashing gray-white water ripple animation

Android cancels RecyclerView, ListView, ScrollView, HorizontalScrollView sliding to the edge and flashing gray-white water ripple animation


When the standard Android RecyclerView, ListView, ScrollView, and HorizontalScrollView slide to the edge, a gray-white water ripple animation will flash. With such a large animation effect, the user has swiped to the edge and cannot slide any more. It is a good design effect for this enhanced experience, but sometimes this effect may not be needed. The way to cancel is to configure the xml layout of RecyclerView, ListView, ScrollView and HorizontalScrollView, and set:
android:overScrollMode="never"
to cancel.

If you want to process it in the upper Java code, you can, for example, in the official Android RecyclerView implementation code:

   /**
     * Set the over-scroll mode for this view. Valid over-scroll modes are
     * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
     * (allow over-scrolling only if the view content is larger than the container),
     * or {@link #OVER_SCROLL_NEVER}.
     *
     * Setting the over-scroll mode of a view will have an effect only if the
     * view is capable of scrolling.
     *
     * @param overScrollMode The new over-scroll mode for this view.
     */
    public void setOverScrollMode(int overScrollMode) {
        if (overScrollMode != OVER_SCROLL_ALWAYS &&
                overScrollMode != OVER_SCROLL_IF_CONTENT_SCROLLS &&
                overScrollMode != OVER_SCROLL_NEVER) {
            throw new IllegalArgumentException("Invalid overscroll mode " + overScrollMode);
        }
        mOverScrollMode = overScrollMode;
    }
You can also set the corresponding mode here.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325472878&siteId=291194637