Skip to content Skip to sidebar Skip to footer

How To Set The Color Of An Android Scrollview Fading Edge?

I have an Android scrollview with a white background. The fading edge is a white translucent gradient. I would like to change it be black instead of white. I have a ListView in the

Solution 1:

If you want a different color fading edge than the background, you have to override the ScrollView's getSolidColor() method. For example:

@Override
publicintgetSolidColor() {
    return Color.rgb(0x30, 0x30, 0x30);
}

Solution 2:

Just found it out by trial and error.

Simply set android:background="@color/yourColor" for the <ScrollView>. It will set the shadow to the given colour.

Solution 3:

You can use:

finalintglowDrawableId= context.getResources().getIdentifier("overscroll_glow",
            "drawable", "android");
    finalDrawableandroidGlow= context.getResources().getDrawable(glowDrawableId);
    androidGlow.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);

    intedgeDrawableId= context.getResources().getIdentifier("overscroll_edge", "drawable",
            "android");
    finalDrawableandroidEdge= context.getResources().getDrawable(edgeDrawableId);
    androidEdge.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);

Solution 4:

You can use this:

https://github.com/AndroidAlliance/EdgeEffectOverride

enter image description here

Simple clean and working perfect!

Solution 5:

EDIT: this does not answer the question, which was asking for ScrollView. This answer only works on AbsListView and descendants (including ListView).


Fading edge color is controlled by the android:cacheColorHint attribute.

E.g.:

<ScrollView android:cacheColorHint="#ff000000" android:background="#ffffffff" />

will set the background to white, and the cacheColorHint is used to draw the fading edge color -- in this case, it would be black.

Post a Comment for "How To Set The Color Of An Android Scrollview Fading Edge?"