How can I change the OverScroll color in Android 2.3.1?

后端 未结 3 1600
一整个雨季
一整个雨季 2020-11-30 23:33

Since Android 2.3.1 there is a new feature for ScrollViews and Lists called OverScroll. With

android:overScrollMode=\"never\"

I can turn i

3条回答
  •  时光说笑
    2020-12-01 00:16

    The following method overrides the standard overscroll color including the edge line.
    Calling it once in onCreate is enough.

    ...
    ChangeOverScrollGlowColor(getResources(), R.color.red);
    ...
    
    public static final void ChangeOverScrollGlowColor( Resources res, int colorID ) {
    
        try {
    
            final int glowDrawableId = res.getIdentifier("overscroll_glow", "drawable", "android");
            final Drawable overscrollGlow = res.getDrawable(glowDrawableId);
            overscrollGlow.setColorFilter(res.getColor(colorID), android.graphics.PorterDuff.Mode.SRC_ATOP);
    
            final int edgeDrawableId = res.getIdentifier("overscroll_edge", "drawable", "android");
            final Drawable overscrollEdge = res.getDrawable(edgeDrawableId);
            overscrollEdge.setColorFilter(res.getColor(colorID), android.graphics.PorterDuff.Mode.SRC_ATOP);
    
        } catch (Exception e) {
        }
    }
    

提交回复
热议问题