Android取消RecyclerView、ListView、ScrollView、HorizontalScrollView滑動到邊緣閃現灰白色水波紋動畫


標准的Android RecyclerView、ListView、ScrollView、HorizontalScrollView滑動到邊緣,會閃現灰白色水波紋動畫,以這樣大的動畫效果提示用戶已經滑動到邊緣,沒法再滑動了。對於這種增強體驗是一個很好的設計效果,但是有時候可能不需要這樣的效果,取消的方法是在配置RecyclerView、ListView、ScrollView、HorizontalScrollView的xml布局里面,設置:

android:overScrollMode="never"

即可取消。

如果要在上層Java代碼處理,也是可以,比如在Android官方的RecyclerView實現代碼中:

 /**
     * 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;
    }

在這里設置相應的mode一樣可以。

 

轉載自:https://yq.aliyun.com/articles/615673


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM