Changing the color of over scroll in scrollview in

2019-01-14 04:48发布

问题:

I have a small problem with my scroll view. Whenever a scroll view has over scrolled, it shows a yellow gradient (in my device, it may vary for other devices) at edges of scroll view. It can be eliminated by setting attribute as below in android 2.3 and above.

android:overScrollMode="never"

Now i want to change the default color to some other. How to achieve this.

Please help me regarding this. Any help will be appreciated.

回答1:

You should use the following attributes on your ListView :

<ListView
      ...
      android:overScrollHeader="@drawable/header"
      android:overScrollFooter="@drawable/footer"/>

You could also set them programatically using setOverscrollFooter(Drawable d) and setOverscrollHeader(Drawable d).



回答2:

This EdgeEffectOverride library works nicely for all scroll-type views: https://github.com/AndroidAlliance/EdgeEffectOverride

E.g.

<uk.co.androidalliance.edgeeffectoverride.EdgeEffectScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    ...
    app:edgeeffect_color="@color/red"
    />

And

EdgeEffectScrollView gridView = (EdgeEffectScrollView) root.findViewById(R.id.myscroll);
gridView.setEdgeEffectColor(Color.RED);