Reputation: 9747
How can I change the overscroll glow effect color of a ViewPager in android? Or is there a way to change the overscroll color for the whole app via themes?
I know of setOverScrollHeader and footer, but these does "logically" of course not work for a viewpager in horizontal mode.
Upvotes: 6
Views: 2248
Reputation: 2508
The simplest way to do it is to override colorPrimary
for your viewpager using themes.
For example :
In your fragment/activity :
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/AppTheme.Viewpager" />
In your file styles.xml
:
<style name="AppTheme.Viewpager" parent="AppTheme">
<item name="colorPrimary">#FFFFFF</item>
</style>
Upvotes: 1
Reputation: 9747
Finally found a solution!!
A great library by AndroidAlliance called EdgeEffectOverride.
It easily allows changing the overscroll color of ScrollView, ListView, ExpandableListView, GridView & ViewPager
Link: https://github.com/AndroidAlliance/EdgeEffectOverride
Upvotes: 0
Reputation: 1285
Solution 1 : You could call inside the scroll listener the methods setBackground, setBackgroundColor and setAlpha methods to create your own appearance.
Solution 2 : You could create your own AlphaAnimation that it will be triggered inside the scroll listener.
AlphaAnimation fadeIn = new AlphaAnimation( 0.0f , 1.0f ) ;
fadeIn.setDuration(1000);
yourViewPager.startAnimation(fadeIn);
Upvotes: 0