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 same project with a white background that has a black fading edge by default, but I can't find where (if anywhere) that was set.
7 Answers
If you want a different color fading edge than the background, you have to override the ScrollView's getSolidColor() method. For example:
@Override
public int getSolidColor() {
return Color.rgb(0x30, 0x30, 0x30);
}

- 897
- 1
- 6
- 6
-
2I don't know why nobody has voted up what is clearly the most general and best answer. Just look at JavaDoc of View and it clearly states as much. – jfelectron Jan 17 '11 at 05:58
-
2He's right, this is the only way to get a colored fade area while using a background image. Just extend the ListView class. – Thomson Comer May 03 '11 at 22:36
-
2A complete class solution for this question is posted here: http://stackoverflow.com/questions/4050903/is-it-possible-to-change-the-colour-of-the-fadingedge-of-a-listview/5877824#5877824 – Thomson Comer May 04 '11 at 02:37
-
The link Thomas Corner mentions does provide a far simpler solution if you just use a color as background for your listview. – bernstein May 16 '11 at 12:29
-
This is the correct answer. This answer must be accepted. Awesome – Ajay Shrestha Oct 21 '16 at 21:25
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.

- 1,872
- 15
- 13
-
Yep, devilishly simple. As you'd imagine, you then just have to set the scrollview immediate child to the background you want. Thanks! – Andrew Shooner Jun 11 '10 at 15:06
-
3Depending on the loading time of the listview this may look awkward. (e.g. listview appears with the background color before the list cells are drawn on top)... – bernstein May 16 '11 at 12:19
-
It would be better to set the same color as background of your cells and the listview. Then just change the cachecolorhint to the desired edge fading color – bernstein May 16 '11 at 12:32
You can use:
final int glowDrawableId = context.getResources().getIdentifier("overscroll_glow",
"drawable", "android");
final Drawable androidGlow = context.getResources().getDrawable(glowDrawableId);
androidGlow.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
int edgeDrawableId = context.getResources().getIdentifier("overscroll_edge", "drawable",
"android");
final Drawable androidEdge = context.getResources().getDrawable(edgeDrawableId);
androidEdge.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);

- 1,404
- 13
- 10
-
1Good article describing this is: http://evendanan.net/android/branding/2013/12/09/branding-edge-effect/ – easycheese Apr 25 '15 at 17:52
You can use this:
https://github.com/AndroidAlliance/EdgeEffectOverride
Simple clean and working perfect!

- 37,109
- 32
- 120
- 141
-
1as I understand the question this is not really the solution, but I was looking for this anyways. So thanks for that – Jakob Harteg Oct 27 '13 at 16:58
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.

- 42,036
- 13
- 45
- 61
-
8I have tried this attribute, but it does not work. It appears that this attribute/method only apply to [AbsListView](http://developer.android.com/intl/fr/reference/android/widget/AbsListView.html#setCacheColorHint%28int%29). – Andrew Shooner Apr 16 '10 at 16:02
-
What about http://developer.android.com/intl/zh-CN/reference/android/view/View.html#setDrawingCacheBackgroundColor%28int%29 ? – Joe Apr 20 '10 at 21:19
-
I had this question about a horizontalscrollview, and the above modifications to the xml worked for it (at least on the emulator). – Gimbl Jan 29 '11 at 16:09
-
This works for me in the emulator (Android 2.3) but not on an actual device (Motorola Razer Android 2.3.5). – sleep Mar 21 '12 at 06:46
-
-
It doesn't work for a ScrollView since that attribute doesn't exist. It works only for ListView. – Dekra Mar 19 '15 at 12:44
If you don't know what changed the color of your fading edge, it was probably the application of a style or theme. Check your manifest for android:theme="something"
in an Activity. If the theme is from the group android.R.style.Theme.Light
the edge will be white. The default android.R.style.Theme
and android.R.style.Theme.Black
will have black fading edges. Themes also affect other attributes, so check out the attributes fully before you throw them in for one thing.

- 11,874
- 2
- 34
- 26
-
I have checked the Activity theme, it is @android:style/Theme.NoTitleBar the [source of which](http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/core/res/res/values/themes.xml&q=Theme.NoTitleBar&sa=N&cd=12&ct=rc) only contains android:windowNoTitle=true. – Andrew Shooner Apr 16 '10 at 16:05
-
1The comment above it: `` So, you are using the dark theme which includes black fading edges. you want `Theme.Light.NoTitleBar` – jqpubliq Apr 16 '10 at 16:53
-
I have changed to this theme, and it has not affected the fading edge color. – Andrew Shooner Apr 16 '10 at 18:50
-
try setting the style on the list itself just to make sure it's not being overridden in a tighter scope – jqpubliq Apr 16 '10 at 19:20
Do this:
<ScrollView
android:theme="@style/scrollUpdate"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
in values\styles put the style
<style name="scrollUpdate">
<item name="colorAccent">@color/yourcolor</item>
<item name="android:color">@color/yourcolor</item>
<item name="colorPrimary">@color/yourcolor</item>
<item name="colorPrimaryDark">@color/yourcolor</item>
</style>
works to me tks!

- 479
- 4
- 7