Skip to main content

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 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.




Comments

  1. 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.

    ReplyDelete
  2. 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);
    }

    ReplyDelete
  3. 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.

    ReplyDelete
  4. 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.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?